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. Image for the cookie policy date
close icon

Adding worksheets to currently active Excel workbook

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


1 Reply

GM Geetha M Syncfusion Team February 23, 2010 08:41 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon