Seconding code-ninja's comment, but perhaps this brings a little more help :-)

If it is not absolutely necessary to create native Excel files, Excel will happily accept CSV files. These are much easier to handle (plaintext, makes debugging much easier).
As you seem to use DBI, perhaps DBD::CSV might come to your rescue, otherwise you could use e.g. Text::CSV.

Comment on Re: Perl Program to load set of columns of table into excel