Copy range with a chart

Hi,

I am using Aspose Cells dll version 4.4.0.0 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

workbook.Open((Stream)stream);



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

dest.Copy(source);



// now save it back as output file

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

“_Out” +Path.GetExtension(templateFile) ;

workbook.Save(outputFile);




Hi,

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?
Thanks.

Hi,

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.

Hi,
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.

Hi,

Thanks for pointing out the issue,

We will figure out the issue soon.

Thank you.

Hi,
Any idea when a solution for this issue would be available?
Thanks.