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");

    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM