https://bz.apache.org/bugzilla/show_bug.cgi?id=60895

Dirk Dittert <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #4 from Dirk Dittert <[email protected]> ---
Dominik,

I am still running into this issue with POI 4.12. The problem is that
CellUtil.setCellStyleProperty() changes the background fill color, the
foreground fill color and the border colors. Here is a snippet of my minimal
example:

public class Demo {

    public static void main(String[] args) throws IOException {
        final Workbook wb = WorkbookFactory.create(new File("Excel.xlsx"));
        final XSSFSheet sheet = (XSSFSheet) wb.getSheet("Tabelle1");
        XSSFRow row = sheet.getRow(1);
        if (row == null) {
            row = sheet.createRow(1);
        }
        final XSSFCell cell = row.createCell(0);
        cell.setCellValue(2.0);

        final DataFormat dataFormat = wb.createDataFormat();
        System.out.println(printCellStyle(cell));
        CellUtil.setCellStyleProperty(cell, CellUtil.DATA_FORMAT,
dataFormat.getFormat("0"));
        System.out.println(printCellStyle(cell));

        wb.write(new FileOutputStream(new
File("/Users/dirk/IdeaProjects/temp/poi-example/src/main/resources/Output.xlsx")));
    }

    // . . . 
}

The output shows for the cell style:

XSSFStyle (Index 0) {
    fillPattern: NO_FILL
    fillForeground: null
    fillBackground: null
    bottomBorder: NONE (null)
    borderLeft: NONE (null)
    borderTop: NONE (null)
    borderRight: NONE (null)
    horizontal alignment: GENERAL
    vertical alignment: BOTTOM
    hidden: false
    locked: true
    rotation: 0°
    indention: 0
    wrap text: false
    dataFormat: 'General' (0)
    font (Index 0) {
        name: Calibri
        size: 12
        bold: false
        italics: false
        strikeout: false
        underline: 0
        color: BLACK1
        typeoffset SS_NONE
     }
}

XSSFStyle (Index 1) {
    fillPattern: NO_FILL
    fillForeground: AUTOMATIC
    fillBackground: AUTOMATIC
    bottomBorder: NONE (BLACK)
    borderLeft: NONE (BLACK)
    borderTop: NONE (BLACK)
    borderRight: NONE (BLACK)
    horizontal alignment: GENERAL
    vertical alignment: BOTTOM
    hidden: false
    locked: true
    rotation: 0°
    indention: 0
    wrap text: false
    dataFormat: '0' (1)
    font (Index 0) {
        name: Calibri
        size: 12
        bold: false
        italics: false
        strikeout: false
        underline: 0
        color: BLACK1
        typeoffset SS_NONE
     }
}

The consequence is that the cell is shown with a white background color in
Excel. This destroys the formatting of Excel data tables. You will then have a
light blue line with white cells in it (those that were created by POI).

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to