setFillForegroundColor() is correct. I know it is strange. Try to understand it by playing with different parameters to setFillPattern. eg. HSSFCellStyle.SOLID_FOREGROUND, NO_FILL, SMALL_DOTS, DIAMONDS, etc. You should then see how the FillBackgroundColor comes in play.

In Excel the difference between foreground and background should relate to the fill pattern.

You will also note that Excel has a color table to deal with as well - your colors need to be in that.

Regards,
Dave

On Oct 3, 2007, at 8:19 AM, Deibys F Quintero wrote:

Paul, thanks a lot !!
easy trick, but useful, by the way , it it a bug in apache poi api that setFillBackgroundColor Does not work ? it would be great if any of you guys (commiters) could make it ? or see if it oem some sort of my current software issue ( Office 2000 SR-1)

thanks !

deibys

----- Original Message ----
From: "Barrett, Paul" <[EMAIL PROTECTED]>
To: POI Users List <[email protected]>
Sent: Wednesday, October 3, 2007 3:58:04 AM
Subject: RE: backgrounf colors for cells do not apply

...I did of course mean setFillForegroundColor() instead of
setFillForeground()... more haste less speed (or caffeine)!

Paul

-----Original Message-----
From: Deibys F Quintero [mailto:[EMAIL PROTECTED]
Sent: 02 October 2007 21:59
To: [email protected]
Subject: backgrounf colors for cells do not apply

hello guys,

I hope some of you can help me.....I am using Apache POI, and it is an
excellent library for generating excel files on the fly
But I have an issue , I am trying to apply background colors to some
cells, but they dont apply,  if I apply font colors, bold ...and so ,
any other style feature it works, but I dont know what happens with
backgrond colors

I am using :
* latest apache poi 3.0.1
* jdk 1.6
* Excel 2000

And Bellow  it is my code;

font3 = book.createFont();
font3.setFontHeightInPoints((short)10);
font3.setFontName(HSSFFont.FONT_ARIAL);
font3.setColor(HSSFColor.BLUE.index);
font3.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

font4 = book.createFont();
font4.setFontHeightInPoints((short)9);
font4.setFontName(HSSFFont.FONT_ARIAL);
font4.setColor(HSSFColor.BLUE.index);
font4.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);


estiloEncabezado1 = book.createCellStyle();
estiloEncabezado2 = book.createCellStyle();

estiloEncabezado1.setFillBackgroundColor(HSSFColor.SKY_BLUE.index);
estiloEncabezado1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
estiloEncabezado1.setFont(font3);
estiloEncabezado2.setFillBackgroundColor(HSSFColor.GREEN.index);
estiloEncabezado2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
estiloEncabezado2.setFont(font4);

..................

y aqui aplico los estilos.........


row = sheet.createRow((short)filaNumber);
cell = row.createCell((short) 0);
value = new HSSFRichTextString("CORRELACIONES");
cell.setCellValue(value);
cell.setCellStyle(estiloEncabezado1);
sheet.addMergedRegion(new
Region(filaNumber,(short)0,filaNumber,(short)6));

filaNumber = filaNumber + 2;

row = sheet.createRow((short)filaNumber);
cell = row.createCell((short) 0);
value = new HSSFRichTextString("No.");
cell.setCellValue(value);
cell.setCellStyle(estiloEncabezado2);
cell = row.createCell((short) 1);
value = new HSSFRichTextString("Indicador");
cell.setCellValue(value);
cell.setCellStyle(estiloEncabezado2);

...........


Fonts and Alignment are applied , but background colors are not...


In the Quick-Guide in the apche poi HSSF documentation , i guess it is
supported , but I am really unsure about what I might be missing

I really appreciate any help

deibys




Send instant messages to your online friends
http://uk.messenger.yahoo.com
Evotec (UK) Ltd is a limited company registered in England and Wales. Registration number:2674265. Registered office: 111 Milton Park, Abingdon, Oxfordshire, OX14 4RZ, United Kingdom.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







Send instant messages to your online friends http:// uk.messenger.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to