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 

Copy some excel sheets to new workbook in Delphi5

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





PostPosted: Wed Jan 28, 2004 7:22 am    Post subject: Copy some excel sheets to new workbook in Delphi5 Reply with 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
Kim Doran
Guest





PostPosted: Wed Jan 28, 2004 10:28 am    Post subject: Re: Copy some excel sheets to new workbook in Delphi5 Reply with 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);

//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





PostPosted: Wed Jan 28, 2004 12:50 pm    Post subject: Re: Copy some excel sheets to new workbook in Delphi5 Reply with quote



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
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.