BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie: Adding Excel WorkSheets?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Scott Kent-Collins
Guest





PostPosted: Thu Jun 26, 2003 12:50 am    Post subject: Newbie: Adding Excel WorkSheets? Reply with quote



I have little experience in Delphi and I am trying to edit some code to add
an extra Worksheet to an Excel spreadsheet. The following code currently
adds 1 worksheet to the spreadsheet fine but now I need to add another
Worksheet to the Spreadsheet:


function OpenSpread( SheetName: String; KP_Type: Byte; var sheet1:
Variant ): Variant;
begin
result := CreateOleObject('Excel.Application');
result.Workbooks.Add(xlWBatWorkSheet);
result.Workbooks[1].WorkSheets[1].Name := SheetName;
sheet1 := result.Workbooks[1].WorkSheets[SheetName];
FormatSpread( result, sheet1, KP_Type);
end;

Thanks in advance
Scott Kent-Collins


Back to top
Mike Shkolnik
Guest





PostPosted: Thu Jun 26, 2003 10:08 am    Post subject: Re: Newbie: Adding Excel WorkSheets? Reply with quote



Just call an Add method again:
result.Workbooks.Add(xlWBatWorkSheet);
What is a problem?

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Scott Kent-Collins" <scott.kent-collins (AT) quest (DOT) com.au> сообщил/сообщила в
новостях следующее: news:3efa4351 (AT) newsgroups (DOT) borland.com...
Quote:
I have little experience in Delphi and I am trying to edit some code to
add
an extra Worksheet to an Excel spreadsheet. The following code currently
adds 1 worksheet to the spreadsheet fine but now I need to add another
Worksheet to the Spreadsheet:


function OpenSpread( SheetName: String; KP_Type: Byte; var sheet1:
Variant ): Variant;
begin
result := CreateOleObject('Excel.Application');
result.Workbooks.Add(xlWBatWorkSheet);
result.Workbooks[1].WorkSheets[1].Name := SheetName;
sheet1 := result.Workbooks[1].WorkSheets[SheetName];
FormatSpread( result, sheet1, KP_Type);
end;

Thanks in advance
Scott Kent-Collins






Back to top
Scott Kent-Collins
Guest





PostPosted: Fri Jun 27, 2003 12:31 am    Post subject: Re: Newbie: Adding Excel WorkSheets? Reply with quote



Hi Mike,

Yeah I have tried that but that creates 2 seperate Workbooks each with its
own WorkSheet. I wanted to knwo how I can add an extra WorkSheet to the
Workbook I have already created in the code below.

Thanks
Scott Kent-Collins

"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote

Quote:
Just call an Add method again:
result.Workbooks.Add(xlWBatWorkSheet);
What is a problem?

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Scott Kent-Collins" <scott.kent-collins (AT) quest (DOT) com.au> сообщил/сообщила в
новостях следующее: news:3efa4351 (AT) newsgroups (DOT) borland.com...
I have little experience in Delphi and I am trying to edit some code to
add
an extra Worksheet to an Excel spreadsheet. The following code
currently
adds 1 worksheet to the spreadsheet fine but now I need to add another
Worksheet to the Spreadsheet:


function OpenSpread( SheetName: String; KP_Type: Byte; var sheet1:
Variant ): Variant;
begin
result := CreateOleObject('Excel.Application');
result.Workbooks.Add(xlWBatWorkSheet);
result.Workbooks[1].WorkSheets[1].Name := SheetName;
sheet1 := result.Workbooks[1].WorkSheets[SheetName];
FormatSpread( result, sheet1, KP_Type);
end;

Thanks in advance
Scott Kent-Collins







Back to top
Mike Shkolnik
Guest





PostPosted: Fri Jun 27, 2003 5:04 am    Post subject: Re: Newbie: Adding Excel WorkSheets? Reply with quote

Do you want to create a new sheet in current workbook? Just call an Add
method for workbook:
result.Workbooks[1].WorkSheets.Add;

--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com

"Scott Kent-Collins" <scott.kent-collins (AT) quest (DOT) com.au> wrote

Quote:
Hi Mike,

Yeah I have tried that but that creates 2 seperate Workbooks each with its
own WorkSheet. I wanted to knwo how I can add an extra WorkSheet to the
Workbook I have already created in the code below.

Thanks
Scott Kent-Collins

"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:3efac646 (AT) newsgroups (DOT) borland.com...
Just call an Add method again:
result.Workbooks.Add(xlWBatWorkSheet);
What is a problem?

--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"Scott Kent-Collins" <scott.kent-collins (AT) quest (DOT) com.au> сообщил/сообщила
в
новостях следующее: news:3efa4351 (AT) newsgroups (DOT) borland.com...
I have little experience in Delphi and I am trying to edit some code
to
add
an extra Worksheet to an Excel spreadsheet. The following code
currently
adds 1 worksheet to the spreadsheet fine but now I need to add another
Worksheet to the Spreadsheet:


function OpenSpread( SheetName: String; KP_Type: Byte; var sheet1:
Variant ): Variant;
begin
result := CreateOleObject('Excel.Application');
result.Workbooks.Add(xlWBatWorkSheet);
result.Workbooks[1].WorkSheets[1].Name := SheetName;
sheet1 := result.Workbooks[1].WorkSheets[SheetName];
FormatSpread( result, sheet1, KP_Type);
end;

Thanks in advance
Scott Kent-Collins









Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.