Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
I am using Spreadsheet::WriteExcel. I need to add many worksheets to a workbook. I need either:
  1. Some way to reorder the worksheets alphabetically by name.
  2. 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.
-- Zeno - Barcelona Perl Mongers http://barcelona.pm.org http://www.javajunkies.org

In reply to Spreadsheet::WriteExcel: How to change order of worksheets? by zeno

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.