Creating Excel file using PHP and downloading excel file

Hello guys,

I got easy way to create excel file using PHP and also it will download on client pc. so let’s go for coding.

Put this two lines in top of your PHP file.

header('Content-type: application/excel');
header('Content-Disposition: attachment; filename="sample.xls"');

Content Disposition header to supply a recommended filename and force the browser to display the save dialog.

now in html body part you can put any content which you want to fill it inside excel file.

Done!

Advertisements

2 thoughts on “Creating Excel file using PHP and downloading excel file

  1. Hey! Would you mind if I share your blog with my twitter group?
    There’s a lot of folks that I think would really appreciate your content. Please let me know. Thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s