1

I've applied a conditional formatting rule for column B in the excel sheet. When I'm trying to get the conditional styles of that particular cell, I get an empty array. I am using the below code to get the conditional styles.

$conditionalStyles = $PHPExcelObj->getActiveSheet()->getStyle('B4')->getConditionalStyles();

I've used setReadDataOnly(false), so as to get all style info. Below is the code I am using to create the reader object.

$PHPExcelObj   = new PHPExcel;
$InputFileType = PHPExcel_IOFactory::identify($path);
$ObjReader     = PHPExcel_IOFactory::createReader($InputFileType);
$ObjReader->setReadDataOnly(false);
$PHPExcelObj->setActiveSheetIndex(0);
$conditionalStyles = $PHPExcelObj->getActiveSheet()->getStyle('B4')->getConditionalStyles();

I couldn't find out what I am doing wrong. Any leads would be very helpful. Thanks

Edit1:

The original file was a .xls file. After I saved it as .xlsx file, I am able to get the conditional styles. The getConditionalStyles() method only works with .xlsx files?

Edit2:

Even with a .xlsx file, it only partially shows the conditional styles. For some cells, even if there is a conditional style rule, it does not show those. Can any one give any idea how can I achieve this. My goal is to get the style info of the cells such as background-color, font-weight, and all.Are there any other Excel reading libraries that I can use apart from PHPExcel?

dr_dev
  • 492
  • 3
  • 17

1 Answers1

-1

Try it without getStyle:

$conditionalStyles = $PHPExcelObj->getActiveSheet()->getConditionalStyles('B4');
Alexander Petrov
  • 13,457
  • 2
  • 20
  • 49
Flo
  • 11
  • 1