Apache POI Excel row color is only black and doesn t change

0 votes

I'm attempting to make the backdrop of Excel files white in one row and aqua in the other. However, no matter what I try, for some reason, the colour always turns black.

private void writeTable(Table table, Row row, CellStyle style){
    if(row.getRowNum() % 2 == 0) {
        style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    }
    style.setWrapText(true);
    Cell cell = row.createCell(0);
    cell.setCellValue(table.index);
    cell.setCellStyle(style);

    //And it continues with other cells
}

It doesn't change whatever I do, even if I try GREY_25_PERCENT it's completely black. Here's a picture of my excel file

Jan 5 in Others by Kithuzzz
• 28,700 points
42 views

1 answer to this question.

0 votes

Use this:

style.setFillPattern(CellStyle.SOLID_FOREGROUND);

In combination with:

style.setFillForegroundColor(IndexedColors.AQUA.getIndex());

Sets the background color of a cell.

answered Jan 6 by narikkadan
• 53,160 points

Related Questions In Others

0 votes
1 answer

Is there a way to hide excel formula using Apache POI

In Excel, hiding formulae is a feature ...READ MORE

answered Oct 11, 2022 in Others by narikkadan
• 53,160 points
215 views
0 votes
1 answer

Is there a way to test a formula result in excel and type it only once, all within one cell and not using a user defined function?

Use the Let function: =LET(Value,A1+B2+C4+G3+B4,IF(Value>10,"No",Value)) I hope this helps ...READ MORE

answered Jan 9 in Others by narikkadan
• 53,160 points
40 views
0 votes
2 answers

What is white box testing and how is it different from black box testing?

Black Box Testing is a software testing method in ...READ MORE

answered Feb 20, 2019 in Others by preetiagarwal
• 170 points
992 views
0 votes
1 answer

What are the RGB and HEX codes of the 3 color conditional format in Excel?

In Excel 2016 at least the colors ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 53,160 points
1,139 views
0 votes
1 answer
0 votes
1 answer

How to get columns from Excel files using Apache POI?

The only way to see all the ...READ MORE

answered Oct 18, 2022 in Others by narikkadan
• 53,160 points
1,020 views
0 votes
1 answer

Apache POI. Setup data filters in Excel

It's already enabled in Apache POI 3.7. ...READ MORE

answered Oct 21, 2022 in Others by narikkadan
• 53,160 points
303 views
0 votes
1 answer

Apache POI - watermark in Excel - different appearance in Excel and LibreOffice

There is nothing that apache poi could ...READ MORE

answered Oct 9, 2022 in Others by narikkadan
• 53,160 points
288 views
0 votes
1 answer

What is the better API to Reading Excel sheets in java - JXL or Apache POI

Here are the things where both APIs ...READ MORE

answered Oct 9, 2022 in Others by narikkadan
• 53,160 points
577 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP