Gembox 获取特定列的所有行(包括空白)的计数
Gembox get count of all rows (including blank) of specfic column
我正在尝试获取特定列最后使用的行数,但只能获取占用的最大行数。测试数据显示在随附的快照中。请帮忙。 Snap Attached Here
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
ExcelFile ef = ExcelFile.Load("test.xlsx");
CellRange rcount = ef.Worksheets[0].Columns[1].Cells;
Console.WriteLine(ef.Worksheets[0].Rows.Count);
ef.Save("test.xlsx");
Console.ReadKey();
单元格在内部按行分配,而不是按列分配。换句话说,您可以使用 ExcelRow.AllocatedCells.Count
.
获取每一行最后使用的列
要获取特定列中最后使用的行,您可以使用如下内容:
ExcelFile ef = ExcelFile.Load("test.xlsx");
ExcelWorksheet ws = ef.Worksheets[0];
ExcelColumn column = ws.Columns[1];
int rowIndex = ws.Rows.Count - 1;
while (rowIndex >= 0 && column.Cells[rowIndex].ValueType == CellValueType.Null)
--rowIndex;
Console.WriteLine(rowIndex);
希望对您有所帮助。
我正在尝试获取特定列最后使用的行数,但只能获取占用的最大行数。测试数据显示在随附的快照中。请帮忙。 Snap Attached Here
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
ExcelFile ef = ExcelFile.Load("test.xlsx");
CellRange rcount = ef.Worksheets[0].Columns[1].Cells;
Console.WriteLine(ef.Worksheets[0].Rows.Count);
ef.Save("test.xlsx");
Console.ReadKey();
单元格在内部按行分配,而不是按列分配。换句话说,您可以使用 ExcelRow.AllocatedCells.Count
.
要获取特定列中最后使用的行,您可以使用如下内容:
ExcelFile ef = ExcelFile.Load("test.xlsx");
ExcelWorksheet ws = ef.Worksheets[0];
ExcelColumn column = ws.Columns[1];
int rowIndex = ws.Rows.Count - 1;
while (rowIndex >= 0 && column.Cells[rowIndex].ValueType == CellValueType.Null)
--rowIndex;
Console.WriteLine(rowIndex);
希望对您有所帮助。