Saturday, 15 January 2011

java - Can't Set Fill Color Apache POI Excel Workbook -


I have scanned this forum as much as possible and mentioned each method here and still changing apache POI Fill in the background color of my Excel document can not be found.

Here's my code:

  errorOccured = true; XSSFCellStyle cs = workbook.createCellStyle (); Cs.setFillBackgroundColor (IndexedColors.RED.getIndex ()); Row.getCell (0) .setCellStyle (CS);   

Do you know why this will not work? What is the correct way to fill row.getCell (0) with red (background color)?

Thank you!

Use a colored color instead of the background color

  Error-protected = true; XSSFCell style style = workbook. Catechyl Style (); Style.setFillForegroundColor (IndexedColors.RED.getIndex ()); Style.setFillPattern (FillPatternType.SOLID_FOREGROUND); Row.getCell (0) .setCellStyle (style);   

It will fill the color of the cell background with red color.

No comments:

Post a Comment