Free Support Forum - aspose.com

AddCopy and chart data source Part II

After copying a worksheet via the worksheets collection .AddCopy method, the data source of a chart is bound to the original worksheet.

http://www.aspose.com/forums/ShowPost.aspx?PostID=1370


The above forum thread shows that this issue is fixed, yet I am having the same problem.

WorksheetA has a chart with a data source of =‘WorksheetA’!$A$23:$M$25
Make a copy of WorksheetA utilizing .AddCopy(“WorksheetA”)
Rename the copy to "2005 WorksheetA"
Rename the original to “2004 WorksheetA"
Both worksheets chart’s data source = ‘2004 WorksheetA’!$A$23:$M$25

The expected result would be:
“2005 WorksheetA” chart data source = ‘2005 WorksheetA’!$A$23:$M$25
"2004 WorksheetA” chart data source = ‘2004 WorksheetA’!$A$23:$M$25

As the previous poster stated, it would be a huge undertaking to dynamically create these charts through the object model because of the complexity and number of different charts that are used in the template.

Thanks in advance for your help.

Which version are you using? Please download and try v3.1.1 at http://www.aspose.com/Downloads/Aspose.Excel/Default.aspx.

The following is my test case and it works fine:

Excel excel = new Excel();
excel.Open("d:\\book1.xls");
excel.Worksheets.AddCopy(0);

excel.Worksheets[0].Name = "2004 WorksheetA";
excel.Worksheets[1].Name = "2005 WorksheetA";

excel.Save("result.xls", SaveType.OpenInExcel, FileFormatType.Default, this.Response);

I was using v3.0.5.

I have downloaded v3.1.1 and the issue is now resolved.

Thank you!