If you can
guarantee that your output will
only be opened by Microsoft Excel itself, you can provide an HTML file with a table in it and Excel will do the appropriate thing. If I'm not mistaken, it will even handle basic CSS, but I wouldn't fool around with your full HTML page. So, you'll want to create a template for the table and include it into the main HTML wrapper template for HTML output and use it with a simplified wrapper for XLS output.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?