使用Spire.Xls读取Execl文件或IO,导出到 DataTable。
public DataTable ReadExecl(string fileName)
{
using (var workbook = new Spire.Xls.Workbook())
{
workbook.LoadFromFile(fileName);
using (var sheet = workbook.Worksheets[0])
{
return sheet.ExportDataTable();
}
}
}