Free Support Forum - aspose.com

Can't copy worksheets

Hi,

Could you please indicate why the following code doesn't work with the attached xls file ? (attached file has been generated via Aspose, and opening then saving the file in Excel fixes the issue)

using System;

using System.Collections.Generic;

using System.Text;

using Aspose.Cells;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

ProdBook();

}

private static void ProdBook()

{

//new Aspose.Cells.License().SetLicense("Aspose.Total.lic");

Workbook book = new Workbook();

Workbook excelChild1 = new Workbook();

excelChild1.Open(@"C:\a.xls", FileFormatType.Excel2003);

foreach (Worksheet ws in excelChild1.Worksheets)

{

book.Worksheets.Add(SheetType.Worksheet);

book.Worksheets[book.Worksheets.Count - 1].Copy(ws);

book.Worksheets[book.Worksheets.Count - 1].Name = ws.Name;

}

book.Worksheets.RemoveAt(0);

book.Save("C:\\book.xls", FileFormatType.Excel2003);

}

}

}

Hi,

Thanks for providing us the template file with code.

We found the issue you have mentioned, we will figure it out soon.

Thank you.