PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » File Formats » Spreadsheet_Excel_Writer » Bug #1256

Excel unable to open multi-sheet files with large strings

Details

Submitted2004-04-21 23:01 UTC
Fromdin-phppear at timelord dot com
StatusDuplicate
PackageSpreadsheet_Excel_Writer
PHP Version4.3.6
OSLinux
Roadmaps(Not assigned)

Comments

[2004-04-21 23:01 UTC] din-phppear at timelord dot com

Description:
------------
Using V1.7.0, Microsoft Excel 2000 is unable to open the created .xls file if the following is true:
o The user users large strings (greater than 255 characters)
o Multiple sheets in the same spreadsheet
o Selected the setVersion(8) command for Excel 97 compatiblity.

The same .xls file -can- be read in KDE's kspread (or was that kcalc?) and OpenOffice's calc programs.

Reproduce code:
---------------
<?php
require_once 'Spreadsheet/Excel/Writer.php';

$workbook = new Spreadsheet_Excel_Writer('test.xls');
$workbook->setVersion(8);

$astring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
//
// Uncomment the next line (so you have a string longer than 255 characters),
// and Microsoft Excel is unable to open it!
//$astring = $astring.$astring.$astring.$astring.$astring.$string.$astring.$astring;

$mworksheet =& $workbook->addWorksheet('My Example');

for ($row = 1; $row < 100; $row++)
{
$mworksheet->writeString($row,0,$astring);
$first = substr($astring,0,1);
$rest = substr($astring,1);
$astring = $rest.$first;
}

$m2worksheet =& $workbook->addWorksheet('My Example 2');
for ($row = 1; $row < 100; $row++)
{
$m2worksheet->writeString($row,0,$astring);
$first = substr($astring,0,1);
$rest = substr($astring,1);
$astring = $rest.$first;

}
$workbook->close();
?>

Expected result:
----------------
The creation of test.xls that can be read under Microsoft's Excel 2000.

Actual result:
--------------
The code ran without error and does produce test.xls. However the file cannot be openned under Excel 2000. In particular, Microsoft appears to try and open it and then fails to do so without generating ANY errors or messages.

The file -does- work under KDE's spreadsheet program and OpenOffice's spreadsheet program.

[2004-04-22 01:23 UTC] xnoguer at php dot net

Could you please try the latest version from cvs?

A bug related to long strings (SST) was recently fixed.

[2004-04-22 20:39 UTC] din-phppear at timelord dot com

Yes - using the version Workbook.php and Worksheet.php in CVS appears to fixed this problem.

[2004-04-22 20:40 UTC] din-phppear at timelord dot com

Closing ticket....