PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » File Formats » Spreadsheet_Excel_Writer » Bug #8601

setNumFormat() for numbers stored as text doesn't work for numbers.

Details

Submitted2006-08-31 19:45 UTC
Fromwizard at roborooter dot com
Assignedprogi1984
StatusClosed
PackageSpreadsheet_Excel_Writer
PHP Version5.2.0 RC2
OSwindows 2000/xp
Roadmaps(Not assigned)

Comments

[2006-08-31 19:45 UTC] wizard at roborooter dot com

Description:
------------
$textFormat->setNumFormat('@') or
$textFormat->setNumFormat(49) doesn't work for formatting data as text (such as numbers that you want stored as text). I referred to open office document for the excel file format (page 160) for the @ and the 49 that should refer to formatting as text. So numbers starting with zero loose their zeros and long numbers show as scientific notation.

Test script:
---------------
<?php
require_once "Spreadsheet/Excel/Writer.php";
$workbook =& new Spreadsheet_Excel_Writer();
$workbook->send('test.xls');
$textFormat =& $workbook->addFormat();
$textFormat->setNumFormat('@'); //or 49
$sheet1 =& $workbook->addWorksheet('Not my first sheet');
$sheet1->setColumn(0,0,20,$textFormat);
$sheet1->write(0,0,"000034534");
$sheet1->write(1,0,"100000298109");
$sheet1->write(2,0,"00324838284");
$sheet1->write(3,0,"00456744675454654556");
$workbook->close();
?>

Expected result:
----------------
000034534
100000298109
00324838284
00456744675454654556

Actual result:
--------------
34534
1E+11
324838284
4.56745E+17