Использую модуль Spreadsheet_Excel_Writer для создания Excel файлов в PHP.
В
php5 возникла такая проблема, что файлы создаются с пустым контентом. На форуме откопал такое:
I created a folder where I had the script that was using spreadsheet excel writer. I then made sure it had read/write permissions set (777). I then used $workbook->setTempDir() to set the temporary directory to use the newly created folder.
Ну т.е. надо указать директорию с правами на запись для создания временных файлов. Ну и сам скрипт приблизительно таков:
code:
<?php
require_once 'Spreadsheet/Excel/Writer.php';
// We give the path to our file here
$workbook = new Spreadsheet_Excel_Writer();
$workbook->send('test.xls');
$worksheet =& $workbook->addWorksheet('My first worksheet');
$workbook->setTempDir('./');
$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);
// We still need to explicitly close the workbook
$workbook->close();
?>