如何使用apache poi在excel文件中隐藏或不隐藏列

ran*_*jan 4 java excel xls apache-poi

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

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

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

San*_*ngh 14

你可以列设置为隐藏/取消隐藏使用

 sheet.setColumnHidden(int columnIndex, boolean hidden); 
Run Code Online (Sandbox Code Playgroud)

例如

 sheet.setColumnHidden(2, true);   // this will hide the column index 2
 sheet.setColumnHidden(2, false);   // this will unhide the column index 2
Run Code Online (Sandbox Code Playgroud)

并且可以使用隐藏或不隐藏列

  sheet.isColumnHidden(int columnIndex);
Run Code Online (Sandbox Code Playgroud)

例如

  sheet.isColumnHidden(2);   //this will check the 2nd column index whether it is hidden or not
Run Code Online (Sandbox Code Playgroud)