【问题标题】:PHP with JavaBridge: POI setting custom background color带有 JavaBridge 的 PHP:POI 设置自定义背景颜色
【发布时间】:2013-09-27 13:13:25
【问题描述】:

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

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

也不行

【问题讨论】:

    标签: apache-poi php-java-bridge poi-hssf hssf


    【解决方案1】:

    setFillForegroundColor 什么都不做

    $cellStyle->setFillPattern(1);

    用前景色填充单元格。

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

    【讨论】:

      猜你喜欢
      • 2020-12-14
      • 2020-01-06
      • 2020-08-18
      • 1970-01-01
      • 1970-01-01
      • 2017-04-14
      • 2015-01-14
      • 1970-01-01
      • 2018-06-29
      相关资源
      最近更新 更多