Move Chart to new Worksheet

Using the Aspose Cells API how do you move a chart to a new worksheet?


In Excel 2010
Right click the chart, select Move and choose “New sheet” radio button.

Using Excel Interop

Microsoft.Office.Interop.Excel.ChartObjects charts = ws.ChartObjects(Type.Missing);
Microsoft.Office.Interop.Excel.ChartObject chartObject = charts.Add(10, 10, 200, 100);
Microsoft.Office.Interop.Excel.Chart chart = chartObject.Chart;
chart.Location(Microsoft.Office.Interop.Excel.XlChartLocation.xlLocationAsNewSheet, “WorksheetName”);

Using the Aspose Cells API I create a chart object and tried to use SizeWithWindow

int chartIndex = worksheet.Charts.AddFloatingChart(
ChartType.ScatterConnectedByLinesWithoutDataMarker, 10, 10, 200, 100);
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
chart.SizeWithWindow = true;

When opening the worksheet in Excel the chart displays correctly, but does not re-size with the parent window. How do you use the Aspose Cells API to display a chart as a worksheet.?

Thanks for your help

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

There is not any direct way to move/copy the chart using Aspose.Cells API(s). However, as a workaround, you can create a new worksheet and copy all the shapes in your existing worksheet into new worksheet.

Once, you will copy all the shapes from existing worksheet into new one, your chart should also be copied into new worksheet.

For your parent window issue, please provide us your runnable sample code and the actual and expected output xls/xlsx files, we will look into your issue and help/advise you asap.

Besides, we have lately done some major enhancements and added new features in our product, so you should also download and give a try to latest offline demos of Aspose.Cells which you can find from theses links.

These demos can work with Visual Studio 2005, 2008 or 2010. Please read the readme.txt file before running the demos.