RE: [PEAR] Pear Spreadsheet_Excel_Writer...
| From: | Michiel Nugter / Restaurantgids dinnersite.nl | Date: | Mon, 18 Jun 2007 14:31:38 +0000 |
| Subject: | RE: [PEAR] Pear Spreadsheet_Excel_Writer... | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27492@lists.php.net to get a copy of this message | ||
Hi,
An example (untested).
<?php
$workbook = new Spreadsheet_Excel_Writer('/path/to/file.xls');
$worksheet =& $workbook->addWorksheet('tab-title');
//add columns - Not necessary!
$worksheet->write(0, 0, 'ID');
$worksheet->write(0, 1, 'Name');
$worksheet->write(0, 2, 'Adress');
$worksheet->write(0, 3, 'City');
//Array data - could ofcourse also come from another source!
$data = Array(
Array(
'id' => 1,
'name' => 'Person 1',
'adress' => 'Adress 1',
'city' => 'City 1'
),
Array(
'id' => 2,
'name' => 'Person 2',
'adress' => 'Adress 2',
'city' => 'City 2'
),
Array(
'id' => 3,
'name' => 'Person 3',
'adress' => 'Adress 3',
'city' => 'City 3'
)
);
//Loop through the data and add it to the Excel file.
foreach($data AS $row => $person)
{
$worksheet->write($row + 1, 0, $person['id']);
$worksheet->write($row + 1, 0, $person['name']);
$worksheet->write($row + 1, 0, $person['adress']);
$worksheet->write($row + 1, 0, $person['city']);
}
$workbook->close();
?>
This should get you started.
-----Oorspronkelijk bericht-----
Van: Tom Synnott [mailto:tom@curiousclothing.com]
Verzonden: maandag 18 juni 2007 14:37
Aan: pear-general@lists.php.net
Onderwerp: [PEAR] Pear Spreadsheet_Excel_Writer...
Hi all,
I've developed a php page which downloads to an excel file, but I
needed to add more functionality and formatting. I have looked at the
PEAR Spreadsheet_Excel_Writer but is way beyond the scope of what I
know... Was hoping I might be able to get some help... Just not 100%
sure how to implement it... A simple example would be great!
Cheers,
Tom
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php