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

Moving a worksheet from one spreadsheet control to another.

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.

1 Reply

PS Pannir Selvam S Syncfusion Team 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 
 


Loader.
Live Chat Icon For mobile
Up arrow icon