首页 > 其他分享 >NPOI解析xlsx数据

NPOI解析xlsx数据

时间:2023-02-20 18:22:46浏览次数:45  
标签:xlsx null sheet int NPOI stream1 workbook 解析

using (Stream stream1 = File.OpenRead(Path))
{
IWorkbook workbook = null;
if (ext == ".xlsx")
{
workbook = new XSSFWorkbook(stream1);
}
else
{
workbook = new HSSFWorkbook(stream1);
}
for (int i = 0; i < workbook.NumberOfSheets; i++)
{
ISheet sheet = null;
sheet = workbook.GetSheetAt(i);

for (int j = 2; j <= sheet.LastRowNum; j++)
{
IRow row = sheet.GetRow(j);
Console.WriteLine(row.GetCell(0).StringCellValue);

}

}
}

标签:xlsx,null,sheet,int,NPOI,stream1,workbook,解析
From: https://www.cnblogs.com/QJZY/p/17138441.html

相关文章