I’m able to save the excel file as .csv using perl like this :
print "Content-type: application/vnd.ms-excel\n";
print "Content-Disposition: attachment;filename=\"file name.xls\"\n\n";
print"Fruits, Cost";
#Then looping on the results.
Yet I need to save this as .xls cause I want to use colours. Any one can help?
I highly recommend Spreadsheet::WriteExcel for your needs. The library is entirely written in Perl, so all you need to do is upload the CPAN library to your web site and specify the specific location. The library documentation and the code snippet below should get you started.