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

Bug #2405 Text concat operator & truncate formula
Submitted: 2004-09-27 08:34 UTC
From: erik at eldata dot se Assigned: progi1984
Status: Closed Package: Spreadsheet_Excel_Writer
PHP Version: 4.3.0 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2004-09-27 08:34 UTC] erik at eldata dot se
Description: ------------ Formulas trying to concat text using the & operator appear to truncate the formula. A formula like =A1&A2 becomes =A1 when opened in Excel. (noted on two different Linux machines, not working on any machine tested with either version 0.6 or 0.8) Reproduce code: --------------- <? require_once ('Spreadsheet/Excel/Writer.php'); $workbook = new Spreadsheet_Excel_Writer("textbug.xls"); $worksheet =& $workbook->addWorksheet('SheetOne'); $worksheet->write(0, 0, "ONE"); $worksheet->write(1, 0, "TWO"); $worksheet->write(2, 0, "=A1&A2"); // Concat two cells $worksheet->write(3, 0, "=\"ONE\"&\"TWO\""); // Concat two constant texts $workbook->close(); ?> Expected result: ---------------- Four Excel cells with ONE TWO ONETWO ONETWO where the last two are concatenations Actual result: -------------- Both concatenations result in cells with only the first value: ONE The formulas are truncated to =A1 ="ONE"

Comments

 [2008-03-24 00:00 UTC] doconnor (Daniel O'Connor)
I can verify this happens with OpenOffice 2.3.1 also. I suspect its not an actual bug per se, and Excel just wants a funky character instead of & What that character is though...
 [2009-08-03 19:13 UTC] progi1984 (Franck Lefevre)
I just implement it : Go in Parser.php : Add it : (just after SPREADSHEET_EXCEL_WRITER_NE (line 94) /** * @const SPREADSHEET_EXCEL_WRITER_CONCAT token identifier for character "&" */ define('SPREADSHEET_EXCEL_WRITER_CONCAT', "&"); Add it : in function _match($token) line 1157 case SPREADSHEET_EXCEL_WRITER_CONCAT: return $token; break; Add it : in function _condition() line 1308 } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_CONCAT) { $this->_advance(); $result2 = $this->_expression(); if (PEAR::isError($result2)) { return $result2; } $result = $this->_createTree('ptgConcat', $result, $result2); } And your first code works !
 [2009-08-04 03:00 UTC] erikltz (Erik Liljencrantz)
Wonderful to have this bug fixed after almost 5 (five!) years! Thanks Franck, I'll try to close the report! :-)
 [2009-08-05 13:37 UTC] progi1984 (Franck Lefevre)
The following patch has been added/updated: Patch Name: Bug2405.patch Revision: 1249461437 URL: http://pear.php.net/bugs/patch-display.php?bug=2405&patch=Bug2405.patch&revision=1249461437&display=1
 [2009-08-05 14:21 UTC] progi1984 (Franck Lefevre)
The following patch has been added/updated: Patch Name: Bug2405.patch Revision: 1249464117 URL: http://pear.php.net/bugs/patch-display.php?bug=2405&patch=Bug2405.patch&revision=1249464117&display=1
 [2009-08-06 13:06 UTC] cweiske (Christian Weiske)
-Assigned To: +Assigned To: progi1984
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.