using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; namespace Universal; public class ExcelReader { public static Dictionary>> Read(string filePath, int startRow) { Dictionary>> sheets = []; using FileStream file = new(filePath, FileMode.Open, FileAccess.Read); for (int i = 0; ; i++) { ISheet sheet; try { sheet = new XSSFWorkbook(file).GetSheetAt(i); if (sheet is null) break; } catch { break; } Dictionary> contents = []; sheets[sheet.SheetName] = contents; for (int row = startRow; row <= sheet.LastRowNum; row++) { if (sheet.GetRow(row) is not IRow currentRow) continue; contents[row] = []; for (int colum = 0; colum < currentRow.LastCellNum; colum++) { ICell cell = currentRow.GetCell(colum); contents[row][colum] = cell?.ToString() ?? string.Empty; } } } return sheets; } }