Friday 30 November 2012

Create xls in PHP – Export to xls

Create xls file in PHP

Here is the code for creating xls files in PHP. If you are not looking for a lot of operations (like column coloring etc) you can use this method. It is very easy and simple for implementation.

You can fetch dynamic data instead of the content variable.

<?PHP
 
// Creating xls files in PHP 
 
$filename  ="excelreport.xls"; 
 
$contents  ="testdata1 \t testdata2 \t testdata3 \t \n"; 
 
$contents  .="testdata1 \t testdata2 \t testdata3 \t \n"; 
 
header('Content-type: application/ms-excel');
 
header('Content-Disposition: attachment; filename='.$filename);
 
echo $contents;
 
?>

You can email us at support@innovativewebz.com for any questions.

No comments:

Post a Comment