[转]用JAVA在读取EXCEL文件时如何判断列隐藏

原文地址:https://www.cnblogs.com/OwenWu/archive/2012/01/03/2310620.html

org.apache.poi.hssf.usermodel.HSSFSheet 

public static void main(String[] args) throws IOException {

String path1 = "C:/Users/Owen/Desktop/temp_/temp.xls";
InputStream is = new FileInputStream(path1);
HSSFWorkbook workbook = new HSSFWorkbook(is);
 
HSSFSheet sheet0 = workbook.getSheetAt(0);
System.out.println(sheet0.isColumnHidden(0));
System.out.println(sheet0.isColumnHidden(1));
System.out.println(sheet0.isColumnHidden(2));
System.out.println(sheet0.isColumnHidden(3));

        int lastRowNum = sheet0.getLastRowNum();

System.out.println((lastRowNum+1)+"行");
for (int r = 0; r <= lastRowNum; r++){
HSSFRow row = sheet0.getRow(r);
if (row == null){
continue;
}
System.out.println("getZeroHeight:"+row.getZeroHeight());//隐藏行的判断
System.out.println("getHeight:"+row.getHeight());
 
}

}

posted @ 2019-04-08 09:57  dirgo  阅读(2301)  评论(0编辑  收藏  举报