Alternative for PHP_excel
I wrote a very simple class for exporting to "Excel XML" aka SpreadsheetML. It's not quite as convenient for the end user as XSLX (depending on file extension and Excel version, they may get a warning message), but it's a lot easier to work with than XLS or XLSX.
http://github.com/elidickinson/php-export-data
Which is the best way to generate excel output in PHP?
There is some class that generates PHP Excel files (real excel files, not that .csv thing).
I use (DEPRICATED) See edit 2:
https://github.com/PHPOffice/PHPExcel
BUT: I have had a problem when trying to read these generated excel files with the java excel READER, so there might be bugs in this PHP script.
EDIT: Nice one: http://www.phpclasses.org/package/2037-PHP-Generate-spreadsheet-files-Excel-xls-XML-format.html
PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.). https://github.com/PHPOffice/PhpSpreadsheet
Lightweight Excel(xls/xlsx) php library needed
Reading only: http://sourceforge.net/projects/phpexcelreader/ 21.5kb
Create your own very simply: http://www.ibm.com/developerworks/opensource/library/os-phpexcel/
Whats the best method for outputting data to an excel spreadsheet using php
If you want cell formatting such as colour, then I'd certainly recommend PHPExcel... although I do have a certain developer's bias.
Despite offering a wide range of additional features, it is easy to use. You don't specify what format of Excel file you want to write, Excel BIFF file or Office Open XML: PHPExcel offers both. It's still supported (unlike many of the alternatives); and there's a lot of examples showing how to use it in the library package itself, and a helpful message board.
Reading Excel xlsx files in PHP without ZipArchive class or PHP extension php_zip enabled
Since version 1.8.0, PHPExcel has offered an alternative built-in Zip handler that can be enabled by setting
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
before loading any files that are zip-based archives such as xlsx or ods
This is slower and uses more memory than PHP's own ZipArchive extension, but provides an alternative if ZipArchive isn't enabled
Most effective way to create Excel files
There are alternatives to PHPExcel, as listed here
But before you dismiss PHPExcel out of hand, I'd like to know why it isn't working. This is something that normally works without any problems; but your code snippet doesn't show anything about saving the file.
How are you saving the file: which writer are you using?
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('/path/to/777/dir/file.xls');
EDIT
or
$file = '/path/to/777/dir/file.xls'; // not viewable by public
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save($file);
The latest version of Open Office will (I believe) read .xlsx files as well, but it does prefer if they have the correct extension.
Note that the Excel5 Writer doesn't support document properties (though Excel2007 does). There is an active work item for this on the PHPExcel issues list.
PHPexcel export what are the best ways to handle large export
Some tips:
- You can try to do the export in a cronjob, so you don't have any limits on browser timeout.
- Increase the memory and execution time in php.ini (or by ini_set)
- Make use of caching tables, first collect data and put them in a temp/caching table. Where the structure of the table is close the structure of the excel. So you have only receive the data from the temp/caching table and write them to a excel
PHPExcel write rows as is , without any calculation / styling
I did a bunch of things that resulted in wayyyy faster performance.
- ran the script outside the IDE
- set memory limit to 3GB
- Used a different version of PHP
Fixed memory leak
$objPHPExcel->disconnectWorksheets() ;
unset($objPHPExcel) ;
I am not sure what solved the issue..
Related Topics
PHP + MySQL Transactions Examples
What Are the Best PHP Input Sanitizing Functions
Jquery Validate Remote Method Usage to Check If Username Already Exists
PHP Function to Generate V4 Uuid
How to Get a File Name from a Full Path With PHP
How to Use Pdo Connection in Other Classes
Accessing $_Cookie Immediately After Setcookie()
How to View Query Error in Pdo PHP
MySQLi Update Throwing Call to a Member Function Bind_Param() Error
Formatting a Number With Leading Zeros in PHP
In PHP, What Is a Closure and Why Does It Use the "Use" Identifier
How to Encrypt and Decrypt a PHP String
Creating Default Object from Empty Value in PHP
What Does the Variable $This Mean in PHP
How to Store and Retrieve Images from a MySQL Database Using PHP