XSSF cell background solid?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

XSSF cell background solid?

Aram Mirzadeh-2
Hi,

Is it me or you can't set a solid background color on cells?

I need to highlight a couple of rows of data, is there any other
alternatives?  I'm already using text coloring for other purposes.

Aram

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XSSF cell background solid?

asookazian
I'm trying to achieve the same result: highlight specific rows (all cells in the row) with yellow and solid (no patterns, just a full fill for the background of the text).

With version 3.16 of POI, highlighting an entire row only works on empty cells in that row.  But highlighting specific cells works fine, see example below.

https://poi.apache.org/spreadsheet/quick-guide.html#FillsAndFrills
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XSSF cell background solid?

Javen O'Neal-2
Did this previously work on older versions of POI?

My guess is that the cell style overrides the row style. The cell style
should unset any property that should be inherited from the row style.

Are you starting with a new workbook and using the code from the linked
quick guide? If not, could you provide the code and/or workbook needed to
reproduce the issue?

On May 31, 2017 09:38, "asookazian" <[hidden email]> wrote:

I'm trying to achieve the same result: highlight specific rows (all cells in
the row) with yellow and solid (no patterns, just a full fill for the
background of the text).

With version 3.16 of POI, highlighting an entire row only works on empty
cells in that row.  But highlighting specific cells works fine, see example
below.

https://poi.apache.org/spreadsheet/quick-guide.html#FillsAndFrills




--
View this message in context: http://apache-poi.1045710.n5.
nabble.com/XSSF-cell-background-solid-tp5715249p5727677.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XSSF cell background solid?

asookazian
This post was updated on .
I've only used 3.16 POI as I'm new to the library.  This will reproduce by setting rowStyle (works ok if you set cellStyle):

import java.io.FileOutputStream;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ReproduceHighlightProblem {

public static void main(String[] args) throws Exception {
       
        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet("new sheet");

        CellStyle cellStyle1 = workbook.createCellStyle();
        cellStyle1.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
        cellStyle1.setFillPattern(CellStyle.SOLID_FOREGROUND);
                   
        Row row = sheet.createRow((short) 0);
        Cell cell = row.createCell(1);
        cell.setCellValue("aaaaaaaaaa");
       
        cell = row.createCell(2);
        cell.setCellValue("bbbbbbbbbbb");
       
        cell = row.createCell(3);
        cell.setCellValue("ccccccccccccccc");
        row.setRowStyle(cellStyle1);
       
        workbook.write(new FileOutputStream("test.xlsx"));
    }

}
Loading...