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;
        }              

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2021-05-25
  • 2021-08-17
  • 2022-12-23
相关资源
相似解决方案