Build excel file in php

Sep 29, 2004
18,656
67
91
Any advice on this? I have data from a database that I want to package into Excel.

If anyone has done this, I'd love advice. Or if anyone knows of a good project that I could leverage off of, that would be great.

FWIW, this data is simple. I just need to get the values I have into the appropriate cells. No color formatting or anything along those lines.
 

PowerEngineer

Diamond Member
Oct 22, 2001
3,601
779
136
An alternative might be to put the data from the database into a CSV file, which will be converted into a spreadsheet when opened in Excel.
 
Sep 29, 2004
18,656
67
91
I might try using a library. And I am considering a tab delimited CVS file. I want a simple solution for a valid XLS file and it is not documented anywhere.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
^ True, but for Excel Microsoft seems to redefine it as "a text file with field separators" :)

The XLS file format is nasty binary goop. I had to write import / export code for it in C++ years ago at another job and it was no fun.

If you decide not to use the easier comma or tab delimited text format, the XLSX format might be easier since it's a Zip archive of XML and other bits.
 
Sep 29, 2004
18,656
67
91
I saw that pear project. I'll give it a shot and see what happens.

The CSV name indicates the use of the comma to separate data fields, but "CSV" is often applied to files using other delimiters. In common usage almost any delimiter-separated text data may be referred to as a CSV file. RFC4180 tries to formalize the CSV format. IMHO, CSV is like saying Kleenex. Kleenex is a brand but even generic facial tissues are aften referred to as Kleenex.