using (FileStream fsRead = File.OpenRead("111.xls"))
{
IWorkbook wk = new HSSFWorkbook(fsRead);
//因为不仅仅是一个表 所以得遍历
for (int i = 0; i < wk.NumberOfSheets; i++)
{
ISheet sheet = wk.GetSheetAt(i);
for (int j = 0; j <= sheet.LastRowNum; j++)
{
IRow row = sheet.GetRow(j);
if (row == null) return;
for (int r = 0; r < row.LastCellNum; r++)
{
ICell cell = row.GetCell(r);//获取单元格
Console.Write(cell + "\t|");
}
Console.WriteLine();
}
}
}

05-11 13:04