setReadDataOnly(true) working?

Feb 17, 2011 at 11:40 PM

I can't seem to tell the difference when using setReadDataOnly(true), is there something I'm missing here?

The object appears to have formatting information either way, so I still have to wade through the extra stuff I don't really need.

Feb 17, 2011 at 11:41 PM

Forgot to mention I'm using PHP 5.2.9 and PHPExcel 1.7.5

Feb 17, 2011 at 11:55 PM

It works


What I can't do is guess why it isn't working in your script.

Feb 18, 2011 at 12:06 AM

$input_file_type = 'Excel2007';
$input_file_path = 'tester.xlsx';

class filter implements PHPExcel_Reader_IReadFilter
   public function readCell($column, $row, $worksheetName = '') {
      if(in_array($column, range('A','A'))) {
         return true;
      else {
         return false;
$filterSubset = new filter();

$objReader = PHPExcel_IOFactory::createReader($input_file_type);
...hopefully the indents worked... never posted on this board before...

Feb 18, 2011 at 12:19 AM
Edited Feb 18, 2011 at 12:19 AM

Then i'm just doing a print_r:


$objReader = $objReader->load($input_file_path);
Feb 18, 2011 at 12:28 AM

What are you expecting to see when you print_r()?

Ensure that you have a cell set to bold, or with a cell alignment, or a number format mask. Then test to see if that formatting data is held against the cell once it's been loaded.

Alternatively, test the memory usage after reading in the workbook both with and without setReadDataOnly(true).


Feb 18, 2011 at 12:54 AM

Oh I see, it's just using default formatting and ignoring what's in the file. Sorry to bother you!

I guess I was expecting to not see formatting properties at all or something...