How To Create Excel File With PHP
You need to format the HTML and CSS using excel friendly CSS and add header information to your PHP script. Like this:
<?php
header(“Content-type:application/vnd.ms-excel”);
header(“Content-Disposition:attachment;Filename=document_name.xls”);
echo “<html>”;
echo “<meta http-equiv=”Content-Type”content=”text/html; charset=Windows-1252″>”;
echo “<body>”;
echo “<b>testdata1</b> t <u>testdata2</u> t n “;
echo “</body>”;
echo “</html>”;
?>
That’s how you can create an EXCEL file using PHP.
Template
You can download the Template here – Download
Further reading: Basic concepts Getting started with Excel Cell References