How to export HTML Table into Excel via PHP

0 Shares
0
0
0
0
0
0
0

Create one variable and save the whole table as a string to that variable and just add below headers lines

//Header information
$header = "Header1" . "\t";
$header .= "Header2" . "\t";
//Reading the data thro' POST
$data= $_POST['header1']. "\t";
$data .= $_POST['header2'] . "\t";
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=xyz.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";