Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.4

Request #8408 Problem with foreach loop
Submitted: 2006-08-10 12:04 UTC
From: soli at freemail dot it Assigned:
Status: No Feedback Package: Spreadsheet_Excel_Writer (version 0.9.0)
PHP Version: 5.0.2 OS: Win2003 EE
Roadmaps: (Not assigned)    
Subscription  


 [2006-08-10 12:04 UTC] soli at freemail dot it (Corrado)
Description: ------------ I'm trying to write to multiple worksheet. First I read a text file, for each line I create a worksheet (since now no problems) than I try to write values into these worksheets (this does not work!). Test script: --------------- $readfile=file("file.txt"); require_once 'Spreadsheet/Excel/Writer.php'; $workbook = new Spreadsheet_Excel_Writer('test.xls'); foreach($readfile as $r){ $r=trim($r); $worksheet =& $workbook->addWorksheet($l); //This works $worksheet->writeString(0, 0, 'Somevalue'); //This does not work $l=""; } $workbook->close(); Expected result: ---------------- I expect an excel file with multiple worksheet populated with values Actual result: -------------- This is the error I find: PHP Fatal error: Call to undefined method PEAR_Error::writeString() in D:\phpwebsite\excel.php on line 7

Comments

 [2006-09-18 10:54 UTC] pear dot php dot net at chsc dot dk (Christian Schmidt)
According to the documentation, $worksheet->addWorksheet() may return a PEAR_Error. You should check the return value using PEAR::isError($worksheet) before calling $worksheet->writeString(). The PEAR_Error object contains an error message explaining what went wrong.
 [2009-11-29 07:40 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2017-03-14 16:02 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!