Friday, 15 July 2011

How to save data on excel xls file using perl? -


I am able to use the excel file using .csv in perl like this:

  print "content-type: application / vnd.ms-excel \ n"; Print "Content-Disposal: Attachment; filename = \" file name.xls \ "\ n \ n"; Print "Fruit, Cost";  

# Then looping on the results.

Still I need to save it as .xls because I want to use colors. Can anyone help you?

The library is written entirely in Perl, so you only need to upload the CPAN library on your web site Need and specify specific locations. You should start the Library document and the code snippet below.

  #! Use / usr / bin / perl -w hard; Use Lib qw (./ lib); #Downloaded Spreadsheet for Written Recovery Library :: WrittenExcel; # Print the header "content-type: app / vnd.ms-excel \ n"; Print "Content-Disclosure: Attachment; File Name = Rollchart.org.org.excel \ n \ n"; # Create a new workbook and create a worksheet in my $ workbook = spreadsheet :: WrittenExcel- & gt; Add new ("-"). My $ Worksheet = $ Workbook-> Add_worksheet ("colorful example"); # Text of red my $ format = $ workbook-> Add_format (); Create a new format with $ format & gt; Set_color ('red'); #Header $ worksheet- & gt; Type (0, 0, "fruit.", $ Format); $ Worksheet- & gt; Type (0, 1, "cost", $ format); # Add data $ worksheet- & gt; Type (1, 0, "apple"); $ Worksheet- & gt; Type (1, 1, "10.25"); # Close the workbook $ Workbook-> Close ();  

No comments:

Post a Comment