Can I reliably create Excel documents from a PHP application on a Linux server?

What is creating Excel documents from a PHP application on a Linux server?

I am interested in creating Excel Office 97 (xls) files. My limited research on this has turned this Pear package . It appears to be in beta since 2006.

Can you share your successes or failures in creating Excel files with PHP? Is there a reliable and mature tool?

Update: for this application I need to generate an Excel file, not just a CSV file.

+4
source share
7 answers

There is something much better than the PEAR package!

PHPExcel

+3
source

I used this PEAR package and it works great for Office'97 -2000 compatible files.

If it's a simple spreadsheet, Office can also handle CSV, which PHP can output natively and easily .

+2
source

How about using tables (a spreadsheet is a table, so that's fine) and throwing those lines at the top of the PHP script that creates the table (s):

header("Content-Type: application/vnd.ms-excel"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

Or you can simply create a CSV file, as Excel can easily open them.

+2
source

I used the PEAR package with great success, but there are some limitations when implementing complex formulas. This has something to do with how Excel stores the formula along with the last calculated result. Sometimes, although the formula is correct, when you open the sheet for the first time, the cells are displayed as empty. When a cell has focus and then loses focus, the calculation is performed and the cell fills.

The library is actually a port from the perl library, which is a little more complete, but has the same problems.

+2
source

I used PERL Spreadsheet :: WriteExcel in several proyects without any problems. You may need to make some corrections and wrappers in order to improve the functionality and simplify it, but I find this in order.

I like it because its platform is independent, quick and easy to configure.

+2
source

The easiest way is to use the header to "fake" the Excel file. Here is the code to start the download in the form of an Excel file, the Excel client will simply analyze any HTML code found (tables, csv, ...) and display it in a good format similar to Excel.

 header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=excel.xls"); 
+1
source

Everything is currently in beta. Do you really need excel files with a forum and all this or you just need to open a list of entries in excel to work?

I usually found that when a client wants to get an Excel file, I can just generate a CSV file, and they can work on it in Excel and add the formulas that they want after the fact.

0
source

All Articles