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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Moving a worksheet from one spreadsheet control to another.

Thread ID:

Created:

Updated:

Platform:

Replies:

125944 Sep 13,2016 06:20 PM UTC Sep 14,2016 01:22 PM UTC WinForms 1
loading
Tags: Spreadsheet
Travis Chambers
Asked On September 13, 2016 06:20 PM UTC

I would like to be able to have two spreadsheet controls on my form and open two separate excel docs into each spreadsheet control. I would then like to move one worksheet from the 2nd spreadsheet control into the 1st spreadsheet. Is this possible? Or is it possible to upload sheets from multiple excel files into one spreadsheetcontrol?

Thank you.

Pannir Selvam S [Syncfusion]
Replied On September 14, 2016 01:22 PM UTC

Hi Travis, 
 
Thanks for using Syncfusion product. 
 
Currently Spreadsheet do not have default support to move the worksheets between the Spreadsheet.  However, you can achieve your requirement by copying the worksheets from one workbook into another workbook using XlsIO and then import that workbook into Spreadsheet2 and remove the worksheet from Spreadsheet1 like below code snippet. 
 
Code snippet[C#]: 
var book = workbook2.Clone(); 
book.Worksheets.AddCopy(spreadsheet1.Workbook.Worksheets[0]); 
book.Worksheets[1].Activate(); 
spreadsheet2.Open(book); 
spreadsheet1.RemoveSheet("Sample"); 
 
Please find the sample for this from below location. 
 
 
 
And also you can combine the worksheets from multiple Excel files into single workbook using XlsIO and import that workbook into the Spreadsheet. 
 
Code Snippet[C#]: 
var engine1 = new ExcelEngine(); 
var workbook1 = engine1.Excel.Workbooks.Open(@"../../Data/Book1.xlsx"); 
var workbook2 = engine1.Excel.Workbooks.Open(@"../../Data/Book2.xlsx"); 
 
//Add the Worksheets of workbook1 into the workbook2. 
workbook2.Worksheets.AddCopy(workbook1.Worksheets); 
 
spreadsheet2.Open(workbook2); 
 
 
Please let us know if you have any queries. 
 
Pannir 
 


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.

Warning Icon 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.Close Icon

;