Re: Excel File Creation
| From: | Xavier Noguer | Date: | Tue, 15 Apr 2003 20:32:43 +0000 |
| Subject: | Re: Excel File Creation | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4860@lists.php.net to get a copy of this message | ||
El Mar 15 Abr 2003 16:22, Joshua Groboski escribió:
> I am attempting to use the Spreadsheet-Excel package. When I run the
> sample given in the documentation, I get garbage back. If the headers are
> sent then I should be prompted to save the file.
Can you read the file if you save it on the server?
Try with this:
<?php
require_once 'Spreadsheet/Excel/Writer.php';
// the file will be saved as sample_file.xls
$workbook = new Spreadsheet_Excel_Writer('sample_file.xls');
$worksheet =& $workbook->addWorksheet('My first worksheet');
// The actual data
$worksheet->write(0, 0, 'Name');
$worksheet->write(0, 1, 'Age');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 30);
$worksheet->write(2, 0, 'Johann Schmidt');
$worksheet->write(2, 1, 31);
$worksheet->write(3, 0, 'Juan Herrera');
$worksheet->write(3, 1, 32);
$workbook->close();
?>