I am using Spreadsheet::WriteExcel. I need to add many worksheets to a workbook. I need either:
- Some way to reorder the worksheets alphabetically by name.
- A method of telling the add_worksheet method where to
insert the new worksheet (it defaults to after the last sheet)
I tried selecting an existing worksheet before using add_worksheet, thinking this would insert the new worksheet after the selected one, but this did not work:
use strict;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new("foo.xls");
my $worksheet1 = $workbook->add_worksheet("alfa");
my $worksheet2 = $workbook->add_worksheet("charlie");
# Select "alfa" thinking "bravo" would insert after
# it... it does not work. Final order remains
# "alfa, charlie, bravo", not "alfa, bravo, charlie"
# as desired.
$worksheet1->select();
my $worksheet3 = $workbook->add_worksheet("bravo");
$workbook->close();
Any insights, perhaps a different module? Thanks.