We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Adding worksheets to currently active Excel workbook

Thread ID:

Created:

Updated:

Platform:

Replies:

93042 Feb 19,2010 02:11 PM Feb 23,2010 03:41 AM Windows Forms 1
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On February 19, 2010 02:11 PM

Hello,

I would like to add a worksheet (to which I have already added some data and a chart) to an already running instance of Excel with an already open workbook. My question is, how do I reference the correct workbook object to which to add the sheet. I would like to say something like

IWorksheet sheet = Application.ActiveWorkBook.Add;

But of course this is not allowed syntax.. Any help would be much appreciated, Thank you in advance


Geetha M [Syncfusion]
Replied On February 23, 2010 03:41 AM

Hi Arnold,

Thank you for your interest in Syncfusion products.

It is possible to add a new worksheet to the existing workbook. Please refer to the code snippet given below.

IWorksheet destSheet = application.ActiveWorkbook.Worksheets.Create();

However, it you have the worksheet created and want to add, please check if the following code would work for you.

IWorksheet destSheet = application.ActiveWorkbook.Worksheets.AddCopy(sourceSheet);

Please try this and let me know if you have any questions.

Regards,
Geetha

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;