Ben
Ben

Reputation: 318

PHP with JavaBridge: POI setting custom background color

can anyone find what's wrong with code ?

  $workbook = new java("org.apache.poi.hssf.usermodel.HSSFWorkbook");
  $cellStyle = $workbook->createCellStyle();

  $palette = $this->workbook->getCustomPalette();
  $palette->setColorAtIndex(0x40, 0, 102, 204);
  $backGroundColor = $palette->getColor(0x40); 

  $cellStyle->setFillForegroundColor($backGroundColor->getIndex());
  ...
  $cell->setCellStyle($cellStyle);

this code won't change background color

anyway

  $cellStyle->setFillForegroundColor(0xc); // 0xc is index of blue
  $cellStyle->setFillBackgroundColor(0xc); 

doesn't work neither

Upvotes: 1

Views: 1269

Answers (1)

Ben
Ben

Reputation: 318

setFillForegroundColor does nothing

$cellStyle->setFillPattern (1);

fills the cell with the foreground color.

http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFCellStyle.html#setFillPattern%28short%29

Upvotes: 2

Related Questions