[]
        
(Showing Draft Content)

获取行和列计数

如果工作表包含大量数据,则手动获取行数和列数会变得很麻烦。

GcExcel 允许用户快速获得特定区域或范围内的行和列计数。

IRange接口的字段和方法表示范围内所有区域的单元格计数。

请参阅以下示例代码以获取工作表中的行计数和列计数。

IRange range = worksheet.getRange("A5:B7, C3, H5:I6");
        
// Cell count is 11. All areas cell count
int cellcount = range.getCount();
System.out.println(cellcount);
        
// Cell count is 11. All areas cell count
int cellcount1 = range.getCells().getCount();
System.out.println(cellcount1);
        
// Row count is 3. First area's row count
int rowcount = range.getRows().getCount();
System.out.println(rowcount);
        
// Column count is 2. First area's column count
int columncount = range.getColumns().getCount();