使用Apache POI进行条件格式化

时间:2015-02-26 22:18:18

标签: java apache-poi jboss6.x

我正在尝试实现一个具有Excel,条件格式的文件。这是我的代码:

        XSSFSheetConditionalFormatting format = hojaReportePI.getSheetConditionalFormatting();
        /* Create a rule where different from 0 */
        XSSFConditionalFormattingRule rule = format.createConditionalFormattingRule(ComparisonOperator.NOT_EQUAL, "0");

        /* Define the font formatting if the rule is met */
        /* The gray color for cells that do not comply with the format */
        XSSFFontFormatting rule_pattern = rule.createFontFormatting();
        rule_pattern.setFontColorIndex(IndexedColors.BLACK.index);

        /* Set yellow background fill for records that match */
        XSSFPatternFormatting fill_pattern = rule.createPatternFormatting();
        fill_pattern.setFillBackgroundColor(IndexedColors.DARK_YELLOW.index);

        /* Create a range of cells to which they apply formatting */
        CellRangeAddress[] data_range = {CellRangeAddress.valueOf(String.valueOf("J1") + ":" + String.valueOf("J") + String.valueOf(datosReportesPI.size()))};

        /* Attach rule to a range of cells */
        format.addConditionalFormatting(data_range, rule);

执行时出现以下错误:

Servlet.service() para servlet Faces Servlet lanz¾ excepci¾n:   
java.lang.ClassNotFoundException: org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl$1ConditionalFormattingList.

我正在使用jboss和apache poi;库poi-ooxml-schemas-3.11-20141221.jar和整个库3.11

请帮助谢谢

0 个答案:

没有答案