Web Development

HTTP Headers for Excel Download in PHP

The Required Headers

In order to create an Excel file and make it downloadable instantly in PHP. I have used PHPExcel, and then I found it necessary to share these useful HTTP headers with you folks.

Content-Type

This specifies in what format the page should be rendered by the browser.

Content-Disposition

This header gives a default file name to the attached file served in the response.

X-Sendfile

Alternatively, one could sett X-Sendfile header and assign its value the absoulte path of the file to be downloaded. Then, x-send file module in Apache server should automatically initialize the optimum headers and serve the file.

Advertisements

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