Free Support Forum - aspose.com

Fail to copy excel data

Hello,

We are using Aspose.Cells version 7.3.0.0 for creating Excel file base on Excel templates.

I would like to combine excel files into one file with several worksheets.

For some reason, some of the excel files cannot copy.

Please follow the attached example:

I would like to create 14 sheets in test.xlt and copy all files into relevant sheets ("1.xlt" into sheet 1, "2.xlt" into sheet 2 and so on...)

Thanks,

Hi,


I have tested your scenario using my sample code(below) to copy each worksheet in all the “xlt” files to paste them into “test.xlt” file and then save as the file “outtest.xlt”. It works fine, all the worksheets are copied fine into the output file.

I am using the latest version/fix: Aspose.Cells for .NET v7.3.4.2. Please try it.

Sample code:

Workbook workbook = new Workbook(“e:\test2\test\test.xlt”);
workbook.Worksheets.Clear();
for (int i = 1; i < 15; i++)
{

Workbook template = new Workbook(@“e:\test2\test” + i.ToString() + “.xlt”);
foreach (Worksheet sheet in template.Worksheets)
{
int j = workbook.Worksheets.Add();
workbook.Worksheets[j].Copy(sheet);
workbook.Worksheets[j].Name = “Sheet”+i.ToString();

}
}
workbook.Save(“e:\test2\test\outtest.xlt”);


I have attached the output file here.

Thank you.