In the past I've just served the HTML document as-is. Excel is perfectly capable of loading an HTML document and parsing it as a spreadsheet. Excel even understands many CSS attributes. All you have to do is add an Excel mime type to the HTTP headers, for example:
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition:Attachment;Filename=htmltable.htm');
readfile('htmltable.html');
Unfortunately this isn't as appealing an option as it used to be. Starting with Excel 2007 the program performs some basic document type confirmation. Because HTML is not XLS (obviously) you get a warning. Excel can still open up the document and display it correctly, but there aren't really any options for disabling the warning.
You might try PHPExcel. I've never used it, but apparently you can use it to convert a document from HTML to XLS:
By combining the reader with the writer it is possible to convert files from one format to another with just 3 lines of code:
$objPHPExcel = PHPExcel_IOFactory::load("XMLTest.xml"); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('covertedXml2Xlsx.xlsx');