PHP

How to export HTML table to excel or pdf in PHP

Pinterest LinkedIn Tumblr
<?php
header('Content-type: application/excel');
$filename = 'filename.xls';
header('Content-Disposition: attachment; filename='.$filename);

$data = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<title>Page Title</title>

</head>

<body>
   <table><tr><td>Cell 1</td><td>Cell 2</td></tr></table>
</body></html>';

echo $data;

?>

Write A Comment

Open chat
Hey Visitor,

How can I help you?