Excel worksheet position

Discussion in 'Perl Misc' started by peter.tilm@gmx.de, Nov 16, 2005.

  1. Guest

    Hello,

    anyone a clue how i can add a new worksheet behind the current last
    worksheet in a workbook? How can i specify the position of an excel
    worksheet?

    BR/
    Peter
    , Nov 16, 2005
    #1
    1. Advertising

  2. wrote in news:1132153718.774525.237960
    @o13g2000cwo.googlegroups.com:

    > anyone a clue how i can add a new worksheet behind the current last
    > worksheet in a workbook? How can i specify the position of an excel
    > worksheet?


    This is not really a Perl question, it is a question about the interface
    Excel provides. You can find out about that interface using the "Object
    Browser" in the Visual Basic Editor in Excel.

    Then, try writing some code to use that interface. If you have problems,
    post the code here after having read the posting guidelines.

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Nov 16, 2005
    #2
    1. Advertising

  3. Guest

    writes:

    > Hello,
    >
    > anyone a clue how i can add a new worksheet behind the current last
    > worksheet in a workbook? How can i specify the position of an excel
    > worksheet?

    use strict;
    use warnings;
    use Win32::OLE;

    my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
    Win32::OLE->new('Excel.Application', 'Quit');

    $Excel->{Visible} = 1;


    my $Book = $Excel->Workbooks->Add();

    $Excel->{SheetsInNewWorkbook} = 1;

    $Book->Worksheets(1)->{NAME} = 'Here when we start';

    my $worksheet = $Book->Worksheets->Add();

    $worksheet->{NAME} = 'Added first';
    $worksheet = $Book->Worksheets->Add();
    $worksheet->{NAME} = 'Added second';


    # number of worksheets in the workbook
    my $sheetcount = $Book->Worksheets->{Count};


    my $lastsheet = $Book->Worksheets($sheetcount);


    # This one gets put after the last worksheet
    # Note that with After => "Thingy"
    # the "Thingy" can be any sheet or chart
    $worksheet = $Book->Worksheets->Add({After => $lastsheet});
    $worksheet->{NAME} = 'Added third';





    /me
    , Nov 16, 2005
    #3
  4. Guest

    Hello!

    thanks, it works!
    schrieb:

    > writes:
    >
    > > Hello,
    > >
    > > anyone a clue how i can add a new worksheet behind the current last
    > > worksheet in a workbook? How can i specify the position of an excel
    > > worksheet?

    > use strict;
    > use warnings;
    > use Win32::OLE;
    >
    > my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
    > Win32::OLE->new('Excel.Application', 'Quit');
    >
    > $Excel->{Visible} = 1;
    >
    >
    > my $Book = $Excel->Workbooks->Add();
    >
    > $Excel->{SheetsInNewWorkbook} = 1;
    >
    > $Book->Worksheets(1)->{NAME} = 'Here when we start';
    >
    > my $worksheet = $Book->Worksheets->Add();
    >
    > $worksheet->{NAME} = 'Added first';
    > $worksheet = $Book->Worksheets->Add();
    > $worksheet->{NAME} = 'Added second';
    >
    >
    > # number of worksheets in the workbook
    > my $sheetcount = $Book->Worksheets->{Count};
    >
    >
    > my $lastsheet = $Book->Worksheets($sheetcount);
    >
    >
    > # This one gets put after the last worksheet
    > # Note that with After => "Thingy"
    > # the "Thingy" can be any sheet or chart
    > $worksheet = $Book->Worksheets->Add({After => $lastsheet});
    > $worksheet->{NAME} = 'Added third';
    >
    >
    >
    >
    >
    > /me
    , Dec 14, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. harshan
    Replies:
    0
    Views:
    521
    harshan
    Jul 20, 2004
  2. =?Utf-8?B?U2hhbyBZb25n?=

    How to delete an Excel worksheet by using ASP.NET?

    =?Utf-8?B?U2hhbyBZb25n?=, May 10, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    1,134
    Martin Dechev
    May 12, 2004
  3. Barbara Vernaeve

    POI HSSF generate 2nd excel worksheet.

    Barbara Vernaeve, Feb 1, 2005, in forum: Java
    Replies:
    0
    Views:
    561
    Barbara Vernaeve
    Feb 1, 2005
  4. Replies:
    1
    Views:
    291
    Mirco Wahab
    Apr 17, 2007
  5. Katja
    Replies:
    1
    Views:
    206
Loading...

Share This Page