 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Scott Kent-Collins Guest
|
Posted: Thu Jun 26, 2003 12:50 am Post subject: Newbie: Adding Excel WorkSheets? |
|
|
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
|
Posted: Thu Jun 26, 2003 10:08 am Post subject: Re: Newbie: Adding Excel WorkSheets? |
|
|
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
|
Posted: Fri Jun 27, 2003 12:31 am Post subject: Re: Newbie: Adding Excel WorkSheets? |
|
|
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
|
Posted: Fri Jun 27, 2003 5:04 am Post subject: Re: Newbie: Adding Excel WorkSheets? |
|
|
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 |
|
 |
|
|
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
|
|