Copyrights © 2012 Jatin Kotadiya. All Rights Reserved . Powered by Blogger.

Wednesday, October 31, 2012

To Create Excel , CSV, Docx or Doc file in php using header

For Excel File
1
2
3
4
5
6
7
8
9
<?php
   header("Pragma: public"); // required
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: private", false); // required for certain browsers
   header("Content-Type: application/vnd.ms-excel");
   header("Content-Disposition: attachment; filename=excel.xls");
   header("Content-Transfer-Encoding: binary")
?>

 
 
For CSV File
1
2
3
4
5
6
7
8
9
<?php
   header("Pragma: public"); // required
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: private", false); // required for certain browsers
   header("Content-Type: application/vnd.ms-excel");
   header("Content-Disposition: attachment; filename=excel.csv");
   header("Content-Transfer-Encoding: binary")
?>
 
 
For Doc File
1
2
3
4
5
6
7
8
9
<?php
   header("Pragma: public"); // required
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: private", false); // required for certain browsers
   header("Content-Type: application/msword");
   header("Content-Disposition: attachment; filename=excel.doc");
   header("Content-Transfer-Encoding: binary")
?>
 

0 comments:

Post a Comment