Pear Spreadsheet writer - writing 0 byte file

Pear Spreadsheet writer - writing 0 byte file

am 04.10.2007 16:13:26 von Paul

When I try examples from the docs, it writes out a 0 byte *.xls file. For
example:
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();

$format_bold =& $workbook->addFormat();
$format_bold->setBold();

$format_title =& $workbook->addFormat();
$format_title->setBold();
$format_title->setColor('yellow');
$format_title->setPattern(1);
$format_title->setFgColor('blue');

$worksheet =& $workbook->addWorksheet();
$worksheet->write(0, 0, "Quarterly Profits for Dotcom.Com", $format_title);
// While we are at it, why not throw some more numbers around
$worksheet->write(1, 0, "Quarter", $format_bold);
$worksheet->write(1, 1, "Profit", $format_bold);
$worksheet->write(2, 0, "Q1");
$worksheet->write(2, 1, 0);
$worksheet->write(3, 0, "Q2");
$worksheet->write(3, 1, 0);

$workbook->send('test.xls');
$workbook->close();
?>My installation is:
PHP 4.3
OpenOffice 2.3 (but it doesn't open in MS Excel either)
OLE 0.5 beta
Spreadsheet_Excel_Writer 0.9.1 beta

Any ideas what's going wrong?

Re: Pear Spreadsheet writer - writing 0 byte file

am 08.10.2007 20:41:12 von sumana.m21

On Oct 4, 7:13 am, "Paul" wrote:
> When I try examples from the docs, it writes out a 0 byte *.xls file. For
> example:
> > require_once 'Spreadsheet/Excel/Writer.php';
> $workbook = new Spreadsheet_Excel_Writer();
>
> $format_bold =& $workbook->addFormat();
> $format_bold->setBold();
>
> $format_title =& $workbook->addFormat();
> $format_title->setBold();
> $format_title->setColor('yellow');
> $format_title->setPattern(1);
> $format_title->setFgColor('blue');
>
> $worksheet =& $workbook->addWorksheet();
> $worksheet->write(0, 0, "Quarterly Profits for Dotcom.Com", $format_title);
> // While we are at it, why not throw some more numbers around
> $worksheet->write(1, 0, "Quarter", $format_bold);
> $worksheet->write(1, 1, "Profit", $format_bold);
> $worksheet->write(2, 0, "Q1");
> $worksheet->write(2, 1, 0);
> $worksheet->write(3, 0, "Q2");
> $worksheet->write(3, 1, 0);
>
> $workbook->send('test.xls');
> $workbook->close();
> ?>My installation is:
> PHP 4.3
> OpenOffice 2.3 (but it doesn't open in MS Excel either)
> OLE 0.5 beta
> Spreadsheet_Excel_Writer 0.9.1 beta
>
> Any ideas what's going wrong?

Yeah you need to specify a filename for the Spreadsheet_Excel_Writer
$workbook = new Spreadsheet_Excel_Writer('filename');