POI隐藏行 隐藏列,EasyExcel隐藏行 EasyExcel隐藏列
因为EasyExcel基于POI的所以隐藏行用的是POI的方式,代码如下
@Test public void test1() throws Exception { String excelPath = "F:\\temp\\SiPrintViewNew111.xls"; HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(excelPath)); HSSFSheet sheet = workbook.getSheetAt(0); //Excel隐藏 80-120行 for (Integer rowIndex = 80; rowIndex < 120; rowIndex++) { Row row = sheet.getRow(rowIndex); row.setZeroHeight(true); } //隐藏 第10列 sheet.setColumnHidden(10,true); FileOutputStream out = null; try { out = new FileOutputStream(excelPath); workbook.write(out); } catch (IOException e) { e.printStackTrace(); } finally { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } System.out.println("OK"); }
欢迎加入JAVA技术交流QQ群:179945282
欢迎加入ASP.NET(C#)交流QQ群:17534377