You can use Win32::OLE.

I have found this module rather helpful for working with Excel. If you want to find out how to do anything, just make an excel macro and look at it -- the VB can be translated to perl VERY easily.

#here's the macro Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess +, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Selection.Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xl +Guess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

If you know the Excel object model you can use that to help. Just take the . and make them method calls, i.e., a.b to a->b. The := assignments are mapped to hashes. So a.b c:=d to a->b( {c => d}).

There're a lot of good resources you can find for this -- I enjoyed the OLE Browser (standard with active perl, I think it's <perl-path>/html/ole-browser

UPDATE:

Here's a quick start:

my $file_name = 'FILE_NAME.xls'; my $xl = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "hlpful err msg"; my $book = $xl->Workbooks->Add(); my $sheet1 = $book->Worksheets(1); $xl->{DisplayAlerts} = 0; $sheet1->{Name} = 'YOUR_SHEET_NAME'; $book->SaveAs($file_name);

In reply to Re: Excel module by dimmesdale
in thread Excel module by DS

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.