1
votes

I am trying to import excel file using phpexcel library.

The excel file contains Name Ranges (which takes data from table in another sheet of same excel file) for data lookup in cells.
I found the function in phpexcel library called getNamedRanges() which is supposed to list the named ranges from excel file. But it returns an empty array.

Code:

<?php
$inputFileType = 'Excel2007';
$inputFileName = $uploads_file;
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setLoadAllSheets();
$objPHPExcel = $objReader->load($inputFileName);
$ranges = $objPHPExcel->getNamedRanges();
var_dump($ranges);

When phpexcel tries to lookup data in range, It throws an exception.
Is there any specific method/s in phpexcel, that I am missing which considers the named ranges defined in excel while formula calculation?

Named ranges should work without issue; but Pivot tables are unsupported in PHPExcel - Mark Baker
You're right. In my recent attempts, I see PHPexcel working fine with named ranges while formula calculation. And the exception I am getting is when PHPexcel tries to lookup data range from pivot table. When I convert pivot table to Defined Named ranges, it executes without any issue. Just wondering, why pivot table is not supported in PHPexcel. - bkesh
Some of the basic logic for pivot tables was developed, so that the pivot data was accessible; but we couldn't get styles for pivots working, and any pivot table that included styles that weren't also used elsewhere in the spreadsheet broke quite spectacularly - Mark Baker
@MarkBaker could you please point me to the place in PhphOffice where I can see implemented parts for Pivot tables? Thanks - Oleg Abrazhaev