I want to download an excel file which contains three sheets using PHP. Can any one help me?
+1
A:
Hi,
If I inderstand correctly, you need to generate an Excel file from PHP ?
If so, take a look at a PEAR component called Spreadsheet_Excel_Writer
In the introduction of the manual, there is an example that looks kinda what you are trying to achieve :
<?php
require_once 'Spreadsheet/Excel/Writer.php';
// Creating a workbook
$workbook = new Spreadsheet_Excel_Writer();
// sending HTTP headers
$workbook->send('test.xls');
// Creating a worksheet
$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);
// Let's send the file
$workbook->close();
?>
It might help you do what you want :-)
If I didn't understand and you only need to read an excel file... Well :
- to download it, you can use curl, or fopen and the like
- to read it,
PHP-ExcelReader
might do the trick
Pascal MARTIN
2009-07-31 15:41:20