I've found that if I'm writing a script to generate an Excel-compatible spreadsheet with formatting, it's often easiest to generate an HTML table. HTML contains all of the formatting markup you could ever need, and Excel is smart enough to parse in the table structure and interpret it as spreadsheet cells.
This may not help you with your current question, but for others that happen upon this thread, it might.