Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.SheetConditionalFormatting


    public void testRead(){
        testRead("WithConditionalFormatting.xls");
    }

    public void test53691() throws IOException {
        SheetConditionalFormatting cf;
        final Workbook wb;
        wb = HSSFITestDataProvider.instance.openSampleWorkbook("53691.xls");
        /*
        FileInputStream s = new FileInputStream("C:\\temp\\53691bbadfixed.xls");
        try {
            wb = new HSSFWorkbook(s);
        } finally {
            s.close();
        }

        wb.removeSheetAt(1);*/
       
        // initially it is good
        writeTemp53691(wb, "agood");
       
        // clone sheet corrupts it
        Sheet sheet = wb.cloneSheet(0);
        writeTemp53691(wb, "bbad");

        // removing the sheet makes it good again
        wb.removeSheetAt(wb.getSheetIndex(sheet));
        writeTemp53691(wb, "cgood");
       
        // cloning again and removing the conditional formatting makes it good again
        sheet = wb.cloneSheet(0);
        removeConditionalFormatting(sheet);       
        writeTemp53691(wb, "dgood");
       
        // cloning the conditional formatting manually makes it bad again
        cf = sheet.getSheetConditionalFormatting();
        SheetConditionalFormatting scf = wb.getSheetAt(0).getSheetConditionalFormatting();
        for (int j = 0; j < scf.getNumConditionalFormattings(); j++) {
            cf.addConditionalFormatting(scf.getConditionalFormattingAt(j));
        }       
        writeTemp53691(wb, "ebad");

        // remove all conditional formatting for comparing BIFF output
        removeConditionalFormatting(sheet);       
View Full Code Here


        removeConditionalFormatting(wb.getSheetAt(0));       
        writeTemp53691(wb, "fgood");
    }
   
    private void removeConditionalFormatting(Sheet sheet) {
        SheetConditionalFormatting cf = sheet.getSheetConditionalFormatting();
        for (int j = 0; j < cf.getNumConditionalFormattings(); j++) {
            cf.removeConditionalFormatting(j);
        }
    }
View Full Code Here

            }
        }

        private void applyColorsThatConcealTheEmptyRows() {
            /* display the NA() values in light gray so they are less visible */
            SheetConditionalFormatting cf = s.getSheetConditionalFormatting();
            ConditionalFormattingRule rule = cf.createConditionalFormattingRule("ISNA(A1)");
            FontFormatting fontFmt = rule.createFontFormatting();
            fontFmt.setFontColorIndex(IndexedColors.GREY_25_PERCENT.index);
            String range;
            if (maxCol() != null) {
                range = String.format("A1:%s1048576", maxCol().toString(Utils.getCaf()));
            } else {
                // TODO fix in a different way
                range = "A1:ZZ1048576";
            }
            CellRangeAddress[] dataRange = { CellRangeAddress.valueOf(range) };
            cf.addConditionalFormatting(dataRange, rule);
        }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.SheetConditionalFormatting

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.