Page 1 of 1

Table data into Excel file

Posted: Wed Mar 19, 2008 1:26 am
by Madhum
Can Some one send me the code for write table data into excel file using PHP.

and can we write the data into excel with the table format(borders,font color..etc)?

thankx

Re: Table data into Excel file

Posted: Wed Mar 19, 2008 8:39 am
by thomas777neo
To point you in the right direction. Create the excel file in the format that you would like it.

Then save it as a html file (or any file where you can view the xml saved). You can then use php to read that file created, using fopen and then pop the information into a buffer, then populate the dynamic data that you require by either using str_replace, loops etc. Then write out the xml back into another file with a .xls extension.

It should then keep your formatting. You could probably also look at meta tags as well.

Tip: If you are populating rows of data, split the xml saved into 3 parts, the header, body and footer. You can then read the header, loop the info into the body and read the footer, then combine it all.

Re: Table data into Excel file

Posted: Wed Mar 19, 2008 9:50 am
by pickle
There are Excel creating libraries you can use to properly create Excel files. PEAR has a couple I think.