隐藏和取消隐藏 Cells

Aspose.Cells - 隐藏和取消隐藏行和列

Aspose.Cells提供了一个类,工作簿,代表一个 Microsoft Excel 文件。 Workbook 类包含一个 WorksheetCollection,它允许访问 Excel 文件中的每个工作表。工作表由工作表班级。 Worksheet 类提供了一个 Cells 集合,代表工作表中的所有单元格。 Cells 集合提供了多种用于管理工作表中的行或列的方法。

Java

 Workbook workbook = new Workbook("workbook.xls");

//Accessing the first worksheet in the Excel file

Worksheet worksheet = workbook.getWorksheets().get(0);

Cells cells = worksheet.getCells();

cells.hideRow(2); //Hiding the 3rd row of the worksheet

cells.hideColumn(1); //Hiding the 2nd column of the worksheet

Apache POI SS - HSSF XSSF - 隐藏/取消隐藏 Cells

为了隐藏行或列,Apache POI SS 提供了 Row.setZeroHeight(boolean) 方法。

Java

 InputStream inStream = new FileInputStream("workbook.xls");

Workbook workbook = WorkbookFactory.create(inStream);

Sheet sheet = workbook.createSheet();

Row row = sheet.createRow(0);

row.setZeroHeight(true);

下载运行代码

下载示例代码