I am trying to parse a xls file using apache poi. Is it possible to check whether a column is hidden or not. How can I get the width of a particular column.
我试图使用apache poi解析xls文件。是否可以检查列是否隐藏。如何获得特定列的宽度。
Example: According to the post here it checks if the row is hidden or not.
示例:根据此处的帖子,它会检查行是否隐藏。
Similarly I want to check the width of a column ( or check if the column is hidden or not)
同样,我想检查列的宽度(或检查列是否隐藏)
2 个解决方案
#1
12
you can set a column as hidden/unhidden by using
您可以使用将列设置为隐藏/取消隐藏
sheet.setColumnHidden(int columnIndex, boolean hidden);
e.g.
例如
sheet.setColumnHidden(2, true); // this will hide the column index 2
sheet.setColumnHidden(2, false); // this will unhide the column index 2
and the column is hidden or not can be checked using
并且可以使用隐藏或不隐藏列
sheet.isColumnHidden(int columnIndex);
e.g.
例如
sheet.isColumnHidden(2); //this will check the 2nd column index whether it is hidden or not
#2
2
The Sheet
class has the method boolean isColumnHidden(int columnIndex)
and also the method int getColumnWidth(int columnIndex)
, however the returned width is a unit of character width. Not sure if that helps you.
Sheet类具有方法boolean isColumnHidden(int columnIndex)以及方法int getColumnWidth(int columnIndex),但返回的宽度是字符宽度的单位。不确定这对你有帮助吗?
#1
12
you can set a column as hidden/unhidden by using
您可以使用将列设置为隐藏/取消隐藏
sheet.setColumnHidden(int columnIndex, boolean hidden);
e.g.
例如
sheet.setColumnHidden(2, true); // this will hide the column index 2
sheet.setColumnHidden(2, false); // this will unhide the column index 2
and the column is hidden or not can be checked using
并且可以使用隐藏或不隐藏列
sheet.isColumnHidden(int columnIndex);
e.g.
例如
sheet.isColumnHidden(2); //this will check the 2nd column index whether it is hidden or not
#2
2
The Sheet
class has the method boolean isColumnHidden(int columnIndex)
and also the method int getColumnWidth(int columnIndex)
, however the returned width is a unit of character width. Not sure if that helps you.
Sheet类具有方法boolean isColumnHidden(int columnIndex)以及方法int getColumnWidth(int columnIndex),但返回的宽度是字符宽度的单位。不确定这对你有帮助吗?