Table data into Excel file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Madhum
Forum Newbie
Posts: 7
Joined: Fri Feb 01, 2008 3:40 am

Table data into Excel file

Post 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
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Re: Table data into Excel file

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Table data into Excel file

Post by pickle »

There are Excel creating libraries you can use to properly create Excel files. PEAR has a couple I think.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply