require_once('PHPExcel-1.7.7/Classes/PHPExcel.php');
$inputFileName = 'RN Tracker.xlsx';
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
if i try following
$objReader->setIncludeCharts(TRUE);
during load i get following error message:
Warning: PHPExcel_Reader_Excel2007::load(): Node no longer exists in /users/pravkum4/html/tracker/PHPExcel-1.7.7/Classes/PHPExcel/Reader/Excel2007.php on line 1518
Notice: Trying to get property of non-object in /users/pravkum4/html/tracker/PHPExcel-1.7.7/Classes/PHPExcel/Reader/Excel2007.php on line 1519
Fatal error: Call to a member function children() on a non-object in /users/pravkum4/html/tracker/PHPExcel-1.7.7/Classes/PHPExcel/Reader/Excel2007.php on line 1519
What mistake i am doing here?
Should i include some additional class for chart?
Does chart option is included by default in load method of reader? chart count gives 0. :((
Sometimes gives correct chart count but rendering doesn't work.
One more thing, what is this code? not working for me. Sometimes i get jpgraph_pie.php missing.
PHPExcel_Settings::setChartRenderer(
PHPExcel_Settings::CHART_RENDERER_JPGRAPH,
dirname(__FILE__).'/../../libraries/Charts/jpgraph3.5.0b1/src'
);
Please provide a tutorial for chart rendering. Thank you so much in Advance.
I have yet to see this issue raised at the PHPExcel sites on either CodePlex or on Github... and to resolve it you'll need to upload a sample file that demonstrates the problem so that we can identify what node no longer exists in the Excel data
Look at this this may help you...
http://phpexcel.codeplex.com/workitem/16
http://phpexcel.codeplex.com/wikipage?title=Examples
Related
Trying to read from a XLSX file with PhpSpreadsheet however getting below error:
PHP Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Exception: Your requested sheet index: -1 is out of bounds. The actual number of sheets is 0. in C:\php\projects\stock\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Spreadsheet.php:678
There is definitely a worksheet and my code below to pull a single cell works fine when I remove the table and just have unformatted data.
$spreadsheet = new PhpOffice\PhpSpreadsheet\Spreadsheet();
$inputFileName = "path/to/temp_file_download.xlsx";
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($inputFileName);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
echo $cellValue = $spreadsheet->getActiveSheet()->getCellByColumnAndRow(2, 2)->getValue();
It seems that saving the file with Excel allows it to work just fine however excel does not complain that it is corrupt etc. I have no control over the actual spreadsheet as generated from an external source.
Just wondering if anyone has had similar issues and have any ideas for working around or what I may be doing wrong?
Tried to use the older PhpExcel also to get this to work however similar issues occur until I save the file again.
Have also tried XLSXReader with similar issues:
PHP Fatal error: Uncaught Exception: File /xl/workbook.xml does not exist in the Excel file in C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php:57
Stack trace:
#0 C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php(70): XLSXReader->getEntryData()
#1 C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php(47): XLSXReader->parse()
#2 C:\php\projects\stock\stock.php(17): XLSXReader->__construct()
#3 {main}
thrown in C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php on line 57
And have seen many issues on web for people having issues reading these files that area created like so however still not sure of a simple workaround.
Adding the workaround mentioned below hack for non standard xlsx seemed to do the trick!
https://github.com/PHPOffice/PHPExcel/issues/1187
Just need to add the class extending the xlsx class to phpspreadsheet then call that class instead and all works!
The following error
Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Reader\Exception: Parameter pos=-12 is invalid
is given when trying to parse a specific xls file.
Code
$inputFileName = "excel.xls";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
$spreadsheet = $reader->load($inputFileName);
The file in question: https://filebin.net/sle19tm0kdgduyne/excel.xls?t=u0itbeue
I have tried using all available readers such as Xlsx, Csv etc and even using the old deprecated PHPExcel library. Nothing can parse this specific file, even though it opens fine with excel on windows.
My end goal is converting this xls file to an array, so i can paste the data into a database.
I think you don't need to use createReader().
Here the example of my worked code.
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$spreadsheet = $reader->load('path/to/file.xls');
Hope this can help you.
I have multiple pdf files of one user. So, I have given an option to our user to see all his document in a single PDF file.
For this, I am using FPDI pdf parser to merge all pdf files in a single file and then show to user. But I am getting below error:
Illegal string offset '/Root' in pdf_parser.php line 90
the function in which this error is thrown is given below:
protected function _readRoot()
{
if ($this->_xref['trailer'][1]['/Root'][0] != self::TYPE_OBJREF) {
throw new \Exception('Wrong Type of Root-Element! Must be an indirect reference');
}
$this->_root = $this->resolveObject($this->_xref['trailer'][1]['/Root']);
}
Can anyone please tell me what kind of issue is this. I have tried a lot as well as googled many things but failed.
Thanks in Advance.
Use-case:
Export data from different apps using batch EXPORT APIs to merge into a master excel file and use it for reporting purpose...
Implementation Details
I'm using Podio export API to get data from an application. Application name is Kall8-number-text (as an example).. here is the code snippet
Code Snippet
$batch_id = PodioItem::export(11804702,"xlsx",array("filters" => array( "kall8-number-text" => "510-592-5916") ));
PodioBatch::get( $batch_id );
$file = PodioFile::get($file_id);
// Download the file. This might take a while...
$file_content = $file->get_raw();
// Store the file on local disk
$path_to_file= "downloads/".$name;
file_put_contents($path_to_file, $file_content);
Problem Description:
I'm trying to read downloaded file using phpexcel library but getting error "You tried to set a sheet active by the out of bounds index: 0. The actual number of sheets is 0"
This error shows that file has NO sheet but it is not true. File has data/sheet and it shows upon opening that file.
One interesting fact, if I open the same excel file (manually by double click) and SAVE without making any change, then same code works fine. In my end to end process, I cannot add a manual step to open file every-time to proceed further...
For your information, I thought this is a PHPExcel bug and contacted Mark Backer (coordinator PHPOffice Suit) and he replied with following remarks which seems true.
"My guess would be non-standard namespacing in the file that's generated, which loading and saving in MS Excel fixes"
File Reading Code
$objReader = new PHPExcel_Reader_Excel2007();
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load('callsheet.xlsx');
$objPHPExcel->setActiveSheetIndex(0);
$dataArray = $objPHPExcel->getActiveSheet()->toArray(null, true,true,true);
var_dump($dataArray);
Error Trace
Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'You tried to set a sheet active by the out of bounds index: 0. The actual number of sheets is 0.' in E:\xampp\htdocs\podioexcel\Classes\PHPExcel.php:688 Stack trace: #0 E:\xampp\htdocs\podioexcel\test.php(18): PHPExcel-
setActiveSheetIndex(0) #1 {main} thrown in E:\xampp\htdocs\podioexcel\Classes\PHPExcel.php on line 688
Can you help me to address this issue? This is holding up my project completely.
File Path: https://drive.google.com/file/d/0B79S561prrEBUDY1NEhXQ1JySWM/view
Original question at Stackoverflow: Error While loading excel sheet Using phpexcel
Ejaz
I have made some changes on a file using PHP and realized nothing was changes after running the code (with no any errors).
I understood that I have to save the file right after I change stuff in it.
When using the 'save' function, I get:
( ! ) Fatal error: Call to undefined method PHPExcel_Worksheet::save() in C:\wamp\www\PHPExcel\excel_fun.php on line 32
this is my function and the way I am calling it:
function save_file(){
global $objPHPExcel;
$objPHPExcel->getActiveSheet()->save('keywords.xlsx');
}
save_file();
I tried using
$objPHPExcel->save('keywords.xlsx'); too without any success
get the same error:
( ! ) Fatal error: Call to undefined method PHPExcel::save() in C:\wamp\www\PHPExcel\excel_fun.php on line 32
so what is the right way to do it?
It's pretty straightforward to save the file, most of the examples do it.
You don't save the individual worksheet (you don't save individual worksheets in MS Excel either), you save the whole spreadsheet (PHPExcel object):
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('keywords.xlsx');