Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Excel worksheet position

Reply
Thread Tools

Excel worksheet position

 
 
peter.tilm@gmx.de
Guest
Posts: n/a
 
      11-16-2005
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

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      11-16-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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 <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html

 
Reply With Quote
 
 
 
 
burlo.stumproot@gmail.com
Guest
Posts: n/a
 
      11-16-2005
(E-Mail Removed) 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
 
Reply With Quote
 
peter.tilm@gmx.de
Guest
Posts: n/a
 
      12-14-2005
Hello!

thanks, it works!
(E-Mail Removed) schrieb:

> (E-Mail Removed) 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make COPY of Worksheet(1) to some other Worksheet ??? Katja Perl Misc 1 01-14-2008 10:26 AM
adding an excel worksheet to a generetad excel file via perl FlorianKraft@gmx.de Perl Misc 1 04-17-2007 12:53 PM
POI HSSF generate 2nd excel worksheet. Barbara Vernaeve Java 0 02-01-2005 04:04 PM
Unable to read particular worksheet from excel file using perl harshan Perl 0 07-20-2004 09:32 PM
How to delete an Excel worksheet by using ASP.NET? =?Utf-8?B?U2hhbyBZb25n?= ASP .Net 5 05-12-2004 08:11 AM



Advertisments