Free Support Forum - aspose.com

Combine Woorkbook - worksheets names lost

How to combine two workbooks and not loosing worksheets name?

When i add the second workbook using combine function, workbook is added to my first workbook but worksheet has some default name - “Sheet1”. In second workbook my worksheet had some specific name…

In many case there are same worksheet name in two Excel files. To avoid this, we changed second workbook's sheet name to default. It's very easy to change those sheet name to your specific name.

int count1 = workbook1.Worksheets.Count;

int count2 = workbook2.Worksheets.Count;

workbook1.Combine(workbook2);

for(int i = 0; i < count2; i ++)

workbook1.Worksheets[i + count1].Name = workbook2.WorksheetsIdea [I];