Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How can we generate Excel File or CSV in PHP code on click

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How can we generate Excel File or CSV in PHP code on click

Postby stephenrodrics » Tue Jun 25, 2013 5:39 am

Hi

I want to create a Excel or csv file when the user clicks on button in PHP, is there any way to do this
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 58
Joined: Thu Mar 14, 2013 6:10 am

Re: How can we generate Excel File or CSV in PHP code on cli

Postby johnj » Tue Jun 25, 2013 6:51 am

use something like this:
Code: Select all
....
header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=somefile.xlsx");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
echo "your text that you want to appear in excel file";


I have not tested this but it is something like this.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron