public static List <ItemInfo> ReadExcel(string ePath) { List <ItemInfo> list = new List <ItemInfo>(); using (System.IO.FileStream stream = System.IO.File.Open(excelPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) { using (ExcelDataReader.IExcelDataReader excelReader = ExcelDataReader.ExcelReaderFactory.CreateOpenXmlReader(stream)) { SetReader(excelReader); excelReader.Read(); for (int i = 1; i < excelReader.RowCount; i++) { excelReader.Read(); ItemInfo info = new ItemInfo(); info.id = GetInt(0); info.name = GetString(1); info.introduce = GetString(2); info.CD = GetInt(3); info.time = GetInt(4); info.price = GetInt(5); list.Add(info); } } } return(list); }
/** 開く。 */ public static System.Data.DataSet Open(Fee.File.Path a_assets_path) { System.Data.DataSet t_workbook = null; try{ using (System.IO.FileStream t_stream = System.IO.File.Open(Fee.File.Path.CreateAssetsPath(a_assets_path, Fee.File.Path.SEPARATOR).GetPath(), System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)){ if (t_stream != null) { using (ExcelDataReader.IExcelDataReader t_reader = ExcelDataReader.ExcelReaderFactory.CreateOpenXmlReader(t_stream)){ if (t_reader != null) { t_workbook = ExcelDataReader.ExcelDataReaderExtensions.AsDataSet(t_reader); } } } } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } return(t_workbook); }