in reply to Excel generation
Try this at the top of your script before you output the data:
use CGI (); # <<--update print CGI::header(-type => 'application/vnd.ms-excel'); [download]