一、NPOI获取行数
可以使用NPOI库中的ISheet类中的LastRowNum属性获取Excel文件中行数
using (FileStream fs =new FileStream(filePath, FileMode.Open, FileAccess.Read)) { IWorkbook workbook = new HSSFWorkbook(fs); ISheet sheet = workbook.GetSheetAt(0); int rowCount = sheet.LastRowNum; }
二、NPOI获取列数
1.row获取列数,表头数量
row.Cells.Capacity
//读取行 IRow row = sheet.GetRow(i); if (row.Cells[0] == null) continue; var value = row.Cells[0].ToString();
row.Cells.Capacity
2.row获取每行单元格数量,去掉null的单元格数量
row.Cells.Count
更多:
NPOI设置word单元格颜色XWPFTableCell.setcolor
NPOI Excel导出报错 Cannot access a closed stream
NPOI Excel导出超出65536行报错 Invalid row number (65536) outside allowable range (0..65535)解决方法
标签:Cells,Excel,NPOI,获取,列数,row From: https://www.cnblogs.com/tianma3798/p/17360028.html