#!/usr/bin/perl use strict; use warnings; use FindBin; use lib $FindBin::RealBin . "/modules"; use Spreadsheet::SimpleExcel; binmode(\*STDOUT); # data for spreadsheet my @header = qw(Header1 Header2); my @data = (['Row1Col1', 'Row1Col2'], ['Row2Col1', 'Row2Col2']); # create a new instance my $excel = Spreadsheet::SimpleExcel->new(); # add worksheets $excel->add_worksheet('Name of Worksheet',{-headers => \@header, -data => \@data}); $excel->add_worksheet('Second Worksheet',{-data => \@data}); $excel->add_worksheet('Test'); # add a row into the middle $excel->add_row_at('Name of Worksheet',1,[qw/new row/]); # sort data of worksheet - ASC or DESC $excel->sort_data('Name of Worksheet',0,'DESC'); # remove a worksheet $excel->del_worksheet('Test'); # sort worksheets $excel->sort_worksheets('DESC'); # create the spreadsheet $excel->output(); # print sheet-names print join(", ",$excel->sheets()),"\n"; # get the result as a string my $spreadsheet = $excel->output_as_string(); # print result into a file and handle error $excel->output_to_file("my_excel.xls") or die $excel->errstr(); $excel->output_to_file("my_excel2.xls",45000) or die $excel->errstr();