private static string GetSheetName(NpoiExcel xls) { string sheetName = "summary"; if (!xls.SheetExists(sheetName)) { foreach (var item in xls.SheetNames()) { if (item.ToLower().IndexOf("summary") == 0) //SUMMARY SHEET-EASW-WY98 { return(item); } } if (xls.SheetExists("sheet1")) { sheetName = "sheet1"; } else { sheetName = ""; } } return(sheetName); }
public static Series ImportSpreadsheet(string fileName) { Console.WriteLine("Reading " + fileName); Series s = new Series("series1", TimeInterval.Daily); var xls = new NpoiExcel(fileName); var sheetNames = xls.SheetNames(); //ExcelUtility xls = new ExcelUtility(fileName); //var sheetNames = ExcelUtility.SheetNames(fileName); foreach (string sheet in sheetNames) { if (Regex.IsMatch(sheet.Trim(), "[0-9]{4}$")) // is 4 digit year { int yr = int.Parse(sheet); Console.WriteLine("Reading sheet:" + sheet); //var tbl = ExcelUtility.Read(fileName, sheet, false); var tbl = xls.ReadDataTable(sheet, false, true); ReadTable(s, yr, tbl); } } return(s); }