5

我正在尝试使用 apache poi 解析 xls 文件。是否可以检查列是否隐藏。如何获得特定列的宽度。

示例:根据此处的帖子,它检查该行是否隐藏。

同样,我想检查一列的宽度(或检查该列是否隐藏)

4

2 回答 2

16

您可以通过使用将列设置为隐藏/取消隐藏

 sheet.setColumnHidden(int columnIndex, boolean hidden); 

例如

 sheet.setColumnHidden(2, true);   // this will hide the column index 2
 sheet.setColumnHidden(2, false);   // this will unhide the column index 2

并且可以使用检查该列是否隐藏

  sheet.isColumnHidden(int columnIndex);

例如

  sheet.isColumnHidden(2);   //this will check the 2nd column index whether it is hidden or not
于 2013-07-16T12:18:37.250 回答
3

该类Sheet有方法boolean isColumnHidden(int columnIndex),也有方法int getColumnWidth(int columnIndex),但是返回的宽度是字符宽度的单位。不确定这是否对您有帮助。

于 2013-07-16T12:13:02.013 回答