Hi,
I think the problem is that you also need to set a Fill Pattern via
setFillPattern(), the default may be "no fill" in Excel, e.g. :
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
Dominik.
On Wed, Apr 15, 2015 at 7:24 PM, Schene, Chris <[email protected]> wrote:
> I am new to the list.
>
> I am also having a problem with this. I am using this Java code in an
> attempt to set Color but it does not work.
>
> /**
> * Creates a cell and aligns it a certain way.
> *
> * @param wb the workbook
> * @param row the row to create the cell in
> * @param i the column number to create the cell in
> * @param halign the horizontal alignment for the cell.
> */
> private void createCell(Workbook wb, Row row, int i, short halign,
> short
> valign, int value) {
> CreationHelper ch = wb.getCreationHelper();
> DataFormat format = wb.createDataFormat();
> Cell cell = row.createCell(i);
> cell.setCellValue(value);
> CellStyle cellStyle = wb.createCellStyle();
>
>
> cellStyle.setDataFormat(format.getFormat("###0"));
>
>
> cellStyle.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
>
> cellStyle.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
>
> cellStyle.setAlignment(halign);
> cellStyle.setVerticalAlignment(valign);
>
> cell.setCellStyle(cellStyle);
>
> }
>
>
>
> Christopher Schene
> Field Engineer, Solution Delivery
>
> 41ST PARAMETER
> A part of Experian
> www.the41st.com
>
>
>
> [email protected]
>
> +1 602.290.9792 mobile
>
>
>
>
>
>
> On 4/15/15, 7:09 AM, "Dominik Stadler" <[email protected]> wrote:
>
>>Hi,
>>
>>Glad that it works, seems multiple people stumbled over this recently,
>>the fix will be included in the next released binaries, either
>>3.12-beta2 or 3.12 final, whichever comes first, we have not decided
>>yet.
>>
>>The fixes were done as part of Bug 56295, SVN changes can be seen at
>>https://svn.apache.org/viewvc?view=rev&rev=1666736
>>
>>Thanks... Dominik.
>>
>>On Wed, Apr 15, 2015 at 11:16 AM, Pankaj <[email protected]> wrote:
>>>
>>> Hi,
>>>
>>> Thanks a ton for your response. Results looks good with test file I was
>>> working with. Do you know which stable release would have this
>>>particular
>>> fix ? And can I know the bug ID to look at the code fix/snippet of the
>>>fix.
>>>
>>> Thanks,
>>> Pankaj
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>http://apache-poi.1045710.n5.nabble.com/Background-Color-for-XLSX-Files-w
>>>hen-usinng-Indexed-Automatic-tp5718484p5718490.html
>>> Sent from the POI - User mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [email protected]
>>For additional commands, e-mail: [email protected]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]