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

Bug #6318 Error found in valid excel formula
Submitted: 2005-12-21 22:12 UTC
From: jon dot bertsch at ucop dot edu Assigned:
Status: No Feedback Package: Spreadsheet_Excel_Writer
PHP Version: 5.0.4 OS: Linux SUSE 9.2
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 31 - 27 = ?

 
 [2005-12-21 22:12 UTC] jon dot bertsch at ucop dot edu
Description: ------------ I get an error with the following formula: VLOOKUP(C22,'Stip rates'!$B$3:$C$69,2) SEW is giving back: Syntax error: , lookahead: , current char: 12 Test script: --------------- The error is coming out of parser.php in function _fact() because the , after first cell is being sent on for some reason. This formula works in a normal excel sheet.

Comments

 [2005-12-22 18:48 UTC] jon dot bertsch at ucop dot edu
Added comment: I forgot to add that the error shows up whether the $ in the formula are escaped or substituted by thier hex code. I've tried to debug where the problem occurs but I can't determine whether it's in _advance() or further down the chain . If I remove the $ in the formula then the particular error disappears. What is happening is that the comma between the first two variables on VLOOKUP is being passed on to _condition() (which doesn't happen with other formulas I tested). Thanks
 [2007-03-02 19:13 UTC] luke at pgtv dot com (Luke)
I am also getting an error with a formula. Granted, this may be my fault, since it is a long formula and therefore easy to mess up. But regardless: =IF(FORECAST($A2146+120,D2112:D2146,$A2112:$A2146)>AVERAGE(D2112:D2146)*1.1,FORECAST($A2146+120,D2112:D2146,$A2112:A2146),AVERAGE(D2112:D2146)*1.1) is the formula. I am generating it by the following code: $formula_avgul = "=IF(FORECAST(\$A". $hostnameEndRow ."+" .$forecast_days .",D" . $hostnameStartRow . ":D" . $hostnameEndRow; $formula_avgul .= ",\$A" . $hostnameStartRow .":\$A" . $hostnameEndRow .")>AVERAGE(D" . $hostnameStartRow .":D"; $formula_avgul .= $hostnameEndRow . ")*1.1,FORECAST(\$A" . $hostnameEndRow . "+" . $forecast_days .",D"; $formula_avgul .= $hostnameStartRow . ":D" . $hostnameEndRow . ",\$A" . $hostnameStartRow .":A" . $hostnameEndRow ."),"; $formula_avgul .= "AVERAGE(D" . $hostnameStartRow . ":D" . $hostnameEndRow . ")*1.1)"; $worksheet->writeFormula($writerow, 3, $formula_avgul); I echoed it to a shell and the $formula_avgul was spit back fine..but when it got written into the excel file it came back as: Syntax error: ,, lookahead: , current char: 29 Everything else is working fine.
 [2008-03-22 12:34 UTC] doconnor (Daniel O'Connor)
Jon / Luke; Any chance of reproduce code - I'm not familar with the package enough to know hwo to reproduce it from the snippets provided.
 [2010-05-04 23:48 UTC] hanqi (Frank St)
using this example I can reproduce the issue <?php require_once "Spreadsheet/Excel/Writer.php"; $xls =& new Spreadsheet_Excel_Writer(); $xls->send("VLOOKUP_error.xls"); $sheet =& $xls->addWorksheet('Sheet1'); $row=0; for ($i=11;$i<15;$i++) { $sheet->write($row,0,'X'.$i); $sheet->write($row,1,$i); $row++; } $sheet->write(20,0,'X13'); // This line causes Syntax error: ,, lookahead: , current char: 21 $sheet->writeFormula(20,1,"=VLOOKUP(A21,A1:B10,2,FALSE)"); $sheet->write(21,1,"'=VLOOKUP(A21,A1:B10,2,FALSE)"); $sheet->write(22,1,"'=VLOOKUP(A21;A1:B10;2;FALSE)"); $xls->close(); ?>
 [2013-09-25 19:56 UTC] hai (Heiko Weber)
The problem is the FALSE, which is not really a function call, because it can stand alone (without brackets). This could be a possible patch to solve it: diff --git pear/Spreadsheet/Excel/Writer/Parser.php pear/Spreadsheet/Excel/Writer/Parser.php index a873034..da02f14 100644 --- pear/Spreadsheet/Excel/Writer/Parser.php +++ pear/Spreadsheet/Excel/Writer/Parser.php @@ -1267,6 +1267,10 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR { return $token; } + elseif (eregi("^true|false$",$token) and !eregi("^[A-Z0-9_]", $this->_lookahead)) + { + return $token; + } return ''; } }