如何检查一列是隐藏或不使用apache poi的excel文件

我想parsing一个xls文件使用Apache poi。 是否有可能检查列是否隐藏。 我怎样才能得到一个特定列的宽度。

例如:根据这里的post,它检查行是否隐藏。

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

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

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 

Sheet类具有boolean isColumnHidden(int columnIndex)方法和int getColumnWidth(int columnIndex) ,但返回的宽度是字符宽度的单位。 不知道这是否有助于你。