//返回指定范围单元格
public ICellRange<ICell> GetCellRange(ISheet ws, CellRangeAddress range)
{
int firstRow = range.FirstRow;
int firstColumn = range.FirstColumn;
int lastRow = range.LastRow;
int lastColumn = range.LastColumn;
int height = lastRow - firstRow + 1;
int width = lastColumn - firstColumn + 1;
List<ICell> temp = new List<ICell>(height * width);
for (int rowIn = firstRow; rowIn <= lastRow; rowIn++)
{
for (int colIn = firstColumn; colIn <= lastColumn; colIn++)
{
IRow row = ws.GetRow(rowIn);
if (row == null)
{
row = ws.CreateRow(rowIn);
}
ICell cell = row.GetCell(colIn);
if (cell == null)
{
cell = row.CreateCell(colIn);
}
temp.Add(c
NPOI 获取指定范围的单元格
最新推荐文章于 2024-06-29 08:55:53 发布
本文介绍如何利用NPOI库在Java中有效地读取Excel文件,并聚焦于从特定范围(R1C2到R3C5)提取单元格数据的方法。
摘要由CSDN通过智能技术生成