C# 读取Excel到DataSet
1 /// <summary> 2 /// 读取Excel文件 3 /// </summary> 4 /// <returns></returns> 5 public static DataSet ReadExcel(string path) 6 { 7 DataSet ds = new DataSet(); 8 using (Stream stream = File.OpenRead(path)) 9 { 10 IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); 11 ds = excelReader.AsDataSet(); 12 } 13 return ds; 14 }
依赖
ExcelDataReader
ExcelDataReader.DataSet