 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Volodymyr A. Guest
|
Posted: Wed Jan 28, 2004 7:22 am Post subject: Copy some excel sheets to new workbook in Delphi5 |
|
|
Hi friends!
Can somebody suggest any ways to insert some sheets to new workbook?
My app must to make reports in separate file from time to time so that to
send them via e-mail to main company office.
Any help will be appreciated
|
|
| Back to top |
|
 |
Kim Doran Guest
|
Posted: Wed Jan 28, 2004 10:28 am Post subject: Re: Copy some excel sheets to new workbook in Delphi5 |
|
|
The code below will create a new workbook with a single worksheet. It then
adds another worksheet:
var
WB : _Workbook;
WS : _WorkSheet;
ADispatch : IDispatch;
begin
LCID := LOCALE_USER_DEFAULT;
WB := XLApp.Workbooks.Add(xlWBATWorksheet, LCID);
//Then to add a single worksheet to the new workbook
ADispatch := WB.Worksheets.Add(EmptyParam, EmptyParam, 1, EmptyParam,
LCID);
//Then cast the ADispatch to a worksheet to use it...
WS := ADispatch as _WorkSheet;
WS.Activate(LCID);
...
//use the worksheet
//Save the workbook...
WB.Save(LCID);
I think to save it as a given name you call WB.SaveCopyAs(AFileName,LCID);
-Kim Doran
"Volodymyr A." <sailorin (AT) vk (DOT) km.ua> wrote
| Quote: | Hi friends!
Can somebody suggest any ways to insert some sheets to new workbook?
My app must to make reports in separate file from time to time so that
to
send them via e-mail to main company office.
Any help will be appreciated
|
|
|
| Back to top |
|
 |
Volodymyr A. Guest
|
Posted: Wed Jan 28, 2004 12:50 pm Post subject: Re: Copy some excel sheets to new workbook in Delphi5 |
|
|
Thnks Kim that's what i need! Many thnks!
Kim Doran <kim.doran (AT) eircom (DOT) net> пишет в
сообщении:40178e1c (AT) newsgroups (DOT) borland.com...
| Quote: | The code below will create a new workbook with a single worksheet. It
then
adds another worksheet:
var
WB : _Workbook;
WS : _WorkSheet;
ADispatch : IDispatch;
begin
LCID := LOCALE_USER_DEFAULT;
WB := XLApp.Workbooks.Add(xlWBATWorksheet, LCID);
file://Then to add a single worksheet to the new workbook
ADispatch := WB.Worksheets.Add(EmptyParam, EmptyParam, 1,
EmptyParam,
LCID);
file://Then cast the ADispatch to a worksheet to use it...
WS := ADispatch as _WorkSheet;
WS.Activate(LCID);
...
file://use the worksheet
file://Save the workbook...
WB.Save(LCID);
I think to save it as a given name you call
WB.SaveCopyAs(AFileName,LCID);
-Kim Doran
"Volodymyr A." <sailorin (AT) vk (DOT) km.ua> wrote in message
news:4017630c (AT) newsgroups (DOT) borland.com...
Hi friends!
Can somebody suggest any ways to insert some sheets to new workbook?
My app must to make reports in separate file from time to time so that
to
send them via e-mail to main company office.
Any help will be appreciated
|
|
|
| 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
|
|