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 #8931

Can not create more than one sheet in a file

Details

Submitted2006-10-10 13:33 UTC
Fromsimon at elroble dot co dot uk
StatusBogus
PackageSpreadsheet_Excel_Writer
PHP Version4.3.4
OSApache Webserver | Windows XL
Roadmaps(Not assigned)

Comments

[2006-10-10 13:33 UTC] simon at elroble dot co dot uk

Description:
------------
I can not create more than 1 sheet in an excel file.
We are running Apache on SuseLinux, and opening the file with MS Office Excel 2003.

No errors occur from the PHP script but Excel displays an alert saying "Unable to read file", this message appears for each sheet in the file. Then another alert with this message appears.

QUOTE:
Microsoft Office Excel File Repair Log

Errors were detected in file 'C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\FileName.xls'
The following is a list of repairs:

Damage to the file was so extensive that repairs were not possible. Excel attempted to recover your formulas and values, but some data may have been lost or corrupted.
END QUOTE

Then we can see the excel file with the 2 sheets but every sheet is completly empty, ie no data in the cells, no formatting or anything.

$Id: PEAR.php,v 1.59 2003/04/03 23:10:10 ssb Exp $
Excel Writer 0.9.1 Beta

Test script:
---------------
include("Spreadsheet/Excel/Writer.php");

$cExcelFile = new Spreadsheet_Excel_Writer();

$cExcelSheet1 = $cExcelFile->addWorksheet('Sheet 1');
$cExcelSheet1->write(0,0,'X');

$cExcelSheet2 = $cExcelFile->addWorksheet('Sheet 2');
$cExcelSheet2->write(0,0,'X');

$cExcelFile->send('FileName.xls');
$cExcelFile->close();

Expected result:
----------------
To be able to generate an Excel file with more than one sheet.

[2006-10-10 13:43 UTC] tuupola at php dot net

You are writing the data to copy of the sheet. Not the sheet belonging to workbook. Using references fix the problem:

http://www.appelsiini.net/~tuupola/test/bug8931.php

-cut-
<?php

include("Spreadsheet/Excel/Writer.php");

$cExcelFile = new Spreadsheet_Excel_Writer();

$cExcelSheet1 =& $cExcelFile->addWorksheet('Sheet 1');
$cExcelSheet1->write(0,0,'X');

$cExcelSheet2 =& $cExcelFile->addWorksheet('Sheet 2');
$cExcelSheet2->write(0,0,'X');

$cExcelFile->send('FileName.xls');
$cExcelFile->close();

?>
-cut-

[2006-10-11 08:32 UTC] simon at elroble dot co dot uk

I`ve been working with the Excel Writer for a year, what I know is only from experimenting, where can I find some tutorials or documentation to help?

Thanks

[2006-10-11 08:33 UTC] simon at elroble dot co dot uk

Please ignore the above, i just found some documents