c# file 上传EXCEL文件,以流的形式读取数据
作者:互联网
1.引入 Aspose.Cells
public void test() { HttpFileCollection filelist = HttpContext.Current.Request.Files; if (filelist != null && filelist.Count > 0) { for (int i = 0; i < filelist.Count; i++) { HttpPostedFile file = filelist[i]; var listData = ReadExcelToTable(file.InputStream).Rows; } } } private DataTable ReadExcelToTable(Stream stream) { DataTable result = new DataTable(); Workbook workbook = new Workbook(); workbook.Open(stream); Cells cells = workbook.Worksheets[0].Cells; result = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, false); return result; }
标签:读取数据,c#,cells,以流,filelist,DataTable,result,file,Cells 来源: https://www.cnblogs.com/jasonlai2016/p/10689159.html