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

Bug #3514 Excel Cell Formatting to Text
Submitted: 2005-02-18 09:39 UTC
From: ankush dot mohile at patni dot com Assigned:
Status: No Feedback Package: Spreadsheet_Excel_Writer
PHP Version: 5.0.2 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-02-18 09:39 UTC] ankush dot mohile at patni dot com
Description: ------------ I am trying to make a certain cell of the excel spreadsheet as Text so I could display a number with a leading zero. e.g. 07432 instead of 7432 Reproduce code: --------------- $text_format =& $workbook->addFormat(); $text_format->setNumFormat('@'); $worksheet->write($i,14,"' ".$colO,$text_format); Expected result: ---------------- expected result 07432 Actual result: -------------- produces result as '07432

Comments

 [2005-02-22 11:03 UTC] smith at backendmedia dot com
doesnt look like a doc bug to me
 [2005-03-16 16:26 UTC] christianm at amplix dot de
similar problem, maybe the same Bug: Description: Two fields, formatted as time-value, contains a time value, but with leading ', so another field, declared as a formula-field can't get the correct SUM of the other two fields. code: $format_time =& $workbook->addFormat(); $format_time->setNumFormat("hh:mm:ss"); $worksheet->write($i,3,"12:00:00",$format_time); expected result: ---------------- 12:00:00 produced result: ----------------- '12:00:00
 [2005-10-19 09:07 UTC] stewartchu at gmail dot com
To cater for leading zero value, add the following to the function write in Worksheet.php function write($row, $col, $token, $format = 0) { // leading zero or string format if ($format->_num_format=='@' || preg_match("/^0/", $token)) return $this->writeString($row,$col,$token,$format); ......... }
 [2005-10-25 21:14 UTC] xnoguer at php dot net
christianm, did you try using writeNumber() ? write() actually calls other methods depending on the type of the third argument given, and you are giving it a string ("12:00:00").
 [2005-10-25 21:18 UTC] xnoguer at php dot net
ankush, if you want to use a numeric value as text in a cell, use writeString(). Is that what you want?