in reply to Sorting spread sheets in Perl via OLE Excel

Ok, I think I see it, if you look at the example vba code in the help file for sort. they give a reference to the sort cell, not just the cell location i.e.

$sheet->Rows("5:35")->Sort($sheet->Range("F5"));
I haven't tested this .. but this is my best guess.


Grygonos

Replies are listed 'Best First'.
Re^2: Sorting spread sheets in Perl via OLE Excel
by Grayarea (Initiate) on Sep 29, 2004 at 09:24 UTC
    You were spot on, that worked as expected
    Thanks,
    Grayarea.
Re^2: Sorting spread sheets in Perl via OLE Excel
by Anonymous Monk on Oct 18, 2017 at 12:06 UTC
    hi, I need to sort my sheet by first column then by 2nd column then by 3rd column. Do you know how I can do this? I know the topic is 13 years old but I really need this :p Thanks by advance :)

      Can you sort the data with Perl before writing to the spreadsheet?


      The way forward always starts with a minimal test.
        nope,

        My spreadsheet is built with others spreadsheets, some data can be identical in those spreadsheet, so i have to write identical data once.

        I guess it would make the algorithm very slow and complicated if i had to sort datas before writing in the spreadsheet.

        But anyway, I found my answer some minutes after I asked for help. Here's the answer if some people need it ;) :

        my $SortOrd1 = $Sheet->Range("A2"); my $SortOrd2 = $Sheet->Range("B2"); my $SortOrd3 = $Sheet->Range("C2"); my $Selection = $Sheet->Range("A:M"); $Selection->Sort( {Key1 => $SortOrd1, Order1 => xlAscending, Key2 => $SortOrd2, Order2 => xlAscending, Key3 => $SortOrd3, Order3 => xlAscending, });