We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Copy range with a chart


I am using Aspose Cells dll version in a Windows .NET application.

What I want to do is to copy a range that includes a chart to another worksheet (in the same workbook).

At the moment, I only get the cell contents copied across without the
chart. Chart location: top left (3,1) and bottom right (20,8).

Thank you very much.

Here is my code:

string templateFile = “ChartCopy.xls”;

string reportFile = FolderHelper.GetTemplatesPath() + @"" + templateFile;

Workbook workbook = new Workbook();

FileStream stream = File.OpenRead(reportFile);

// open now


Worksheet sourceSheet = workbook.Worksheets[0];

// report is sheet 0

Worksheet destSheet = workbook.Worksheets[1];

// copy

Range source = sourceSheet.Cells.CreateRange(0, 0, 30, 15);

// destination range

Range dest = destSheet.Cells.CreateRange(0, 0, 30,15);

// now copy


// now save it back as output file

string outputFile = FolderHelper.GetReportOutputPath() + Path.GetFileNameWithoutExtension(templateFile) +

“_Out” +Path.GetExtension(templateFile) ;



Thanks for considering Aspose.

Well, I 'm afraid charts in a range will not be copied when you copy a range (having chart(s)) to other place in the same worksheet or different worksheet. We will support this feature version but this feature could not be completed in a short time.

I thin currently as a workaround, if you want only pic of a chart, you can take the pic of the chart using Chart.ToImage() method and paste the image to other place. Alternatively, you may copy the complete source worksheet using Worksheet.Copy() method and deleted your unwanted portions.

Thank you.

Thank you, Amjad.
Our requirement is to copy charts (not images), so the workaround wouldn’t work for us. This is a standard Excel feature and we thought we can do the same using Aspose Cells. Any timeframe when this feature might make it to a production release?


Please try this fix.

We have supported to copy the chart in coping range.

Warren, thank you very much. The new dll you sent does work as expected.

Chart copy works well. However, I have discovered a little issue.
I use Charts.RemoveAt(0) to remove the chart copied by the range copy and this causes no exception and the Charts.Count goes to 0 as it should. However, when I try to save the workbook an exception occurs. The exception message is: Object reference not set to an instance of an object.

If I save the workbook without removing the chart, no exception occurs.
Could you help?


Thanks for pointing out the issue,

We will figure out the issue soon.

Thank you.

Any idea when a solution for this issue would be available?