1

谁能发现代码有什么问题?

  $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);

此代码不会更改背景颜色

反正

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

也不行

4

1 回答 1

2

setFillForegroundColor 什么都不做

$cellStyle->setFillPattern (1);

用前景色填充单元格。

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

于 2013-09-22T16:14:18.293 回答