poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asookazian <asookaz...@gmail.com>
Subject Re: XSSF cell background solid?
Date Wed, 31 May 2017 17:26:14 GMT
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


Mime
View raw message