asp.net 使用NPOI读取excel文件
asp.net 使用NPOI读取excel文件内容 NPOI下载地址: NPOI public class ExcelHelper { /// <summary> /// 读取Excel文件数据到DataSet,一个Sheet对应一个DataTable /// </summary> /// <param name="strExcelFilePath">Excel文件的物理路径</param> /// <returns></returns> public static DataSet GetDataFromExcel(string strExcelPhysicalPath, out string strError) { try { DataSet dsResult = new DataSet(); strError = ""; IWorkbook wbook = null; using (FileStream fs = new FileStream(strExcelPhysicalPath, FileMode.Open, FileAccess.Read)) { if (strExcelPhysicalPath.IndexOf(".xlsx") > 0) { wbook = new XSSFWorkbook(fs); } else { wbook = new HSSFWorkbook