Aspose.Cells
Excel to datatable 超级快!
class Program { private static string _vsPath = @"D:\work\1207\Parametros OMC_new_Marcelo_imported.xlsm"; private static DateTime _vdtStart; static void Main(string[] args) { Workbook workbook = new Workbook(); workbook.Open(_vsPath); #region Test cell /* _vdtStart = DateTime.Now; Cells cells = workbook.Worksheets[1].Cells; for (int i = 0; i < cells.MaxDataRow + 1; i++) { for (int j = 0; j < cells.MaxDataColumn + 1; j++) { string s = cells[i, j].StringValue.Trim(); //一行行的读取数据,插入数据库的代码也可以在这里写 Console.WriteLine(s); } } */ #endregion Cells cells = workbook.Worksheets[1].Cells; System.Data.DataTable dataTable = cells.ExportDataTable(1, 0, cells.MaxDataRow,cells.MaxColumn); Console.WriteLine("Over!TimeSpan:{0}", DateTime.Now - _vdtStart); Console.Read(); } }