Merging Sheets of several Workbooks into a given Workbook

Hi,

quick question: I need to take a couple of sheets from several different Workbooks and merge these sheets at defined locations into another Workbook. The target indices / locations within the target workbook are determined by placeholder Worksheets with the name names as the ones found in the other Workbooks.

Example

Workbook1.xls contains Sheet 1 and Sheet 2
Workbook2.xls contains Sheet 4

These are being generated / populated by my application. Now I have a Workbook3.xls that contains (empty) sheets (in that order) Sheet 1, Sheet 4, Sheet 2. I need to take the sheets from the other two Workbooks and place them in Workbook3.xls at the locations identified by the placeholder sheets.

What would be the best way to accomplish this? Is there any way I could do this?

Excel.Combine()? But how would I move my sheets around? Setting the Worksheet.Index? Using AddCopy() and then deleting the original sheet?

Any suggestions / help would be highly appreciated

Thanks in advance

Regards

Kai

Laurence,

never mind, found it. Worksheet.Copy() does the trick (mostly). Please see my other / private post regarding an issue I have with merging the sheets.

Regards

Kai

@Kai_Iske,
Aspose.Cells is the latest product that has replaced Aspose.Excel which is no more available now. You can combine multiple workbooks into a single workbook using the following sample code with Aspose.Cells.

// Define the first source
// Open the first excel file.
Workbook SourceBook1 = new Workbook(dataDir+ "SampleChart.xlsx");

// Define the second source book.
// Open the second excel file.
Workbook SourceBook2 = new Workbook(dataDir+ "SampleImage.xlsx");

// Combining the two workbooks
SourceBook1.Combine(SourceBook2);

dataDir = dataDir + "Combined.out.xlsx";
// Save the target book file.
SourceBook1.Save(dataDir);

You can get more information about combining multiple workbooks into a single workbook:
Combine Multiple Workbooks into a Single Workbook

Give a try to this new product by downloading it from the following link:
Aspose.Cells for .NET (Latest Version)

A ready to run solution is available here that can be used to test the variety of features of this new product.