2

I have written code for color formatting for excel using Apache POI. The formatting for color and font came nicely in MS Excel 2010. But it does not have compatibility with excel 2003. The formatting is not there when the file opened in MS Excel 2003.

Here the sample code:

    CellStyle style = getWorkbook().createCellStyle();

    Font font = wb.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    font.setFontHeightInPoints((short)11);

    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);

    Cell cell = excelRow.createCell(10);
    cell.setCellStyle(style);

If any suggestions, let me know.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
undisputed
  • 180
  • 3
  • 12

1 Answers1

1

I had also faced same problem .it is nothing about excel version.We must create styles before the loop and apply styles to specific cells after creating.

https://stackoverflow.com/a/11792648/1211000(it might help )

Community
  • 1
  • 1
swamy
  • 1,200
  • 10
  • 23