You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by asookazian <as...@gmail.com> on 2017/05/31 16:37:59 UTC

Re: XSSF cell background solid?

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: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XSSF cell background solid?

Posted by asookazian <as...@gmail.com>.
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"));
    }

}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XSSF cell background solid?

Posted by Javen O'Neal <on...@apache.org>.
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" <as...@gmail.com> 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: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org