I’m sure there are some libraries or php classes that you can use to convert HTML to Excel spreadsheet. But there is a quick solution that worked for me. Before outputting your HTML to browser, just add these lines at top:
[php]<?php
header(“Content-type: application/vnd.ms-excel”);
header(“Content-Disposition: attachment; filename=your_file_name.xls”);
?>[/php]
This is not really converting html to xls, but this will tell your browser to open the file with MS Excel (and Excel opens HTML tables just as spreadsheet). You can style your table cells with CSS, justify cell content etc. - Excel will recognize all the HTML/CSS formatting.