Aspose.Slides.NET
version: 20.8.0
.Net Core
version: 2.2
When the IChartData.SetRange
method is called for a Bubble chart with a formula that includes a number of columns not divisible by 3, an ArgumentException
is thrown.
For a Bubble chart, the first column in the workbook holds the X values, and the second and third hold the Y and size values of the series. To add another series, you need another set of Y and size columns, like this:
workbook.png (6.8 KB)
In Powerpoint that workbook results in the following chart:
chart.png (10.0 KB)
Doing that with Aspose.Slides
seems to be impossible for a predefined template.
Even running the template through the SetRange
method with its existing formula throws an exception.
Here is an example console app and a template: bubble_chart.zip (38.7 KB)
The code I’m trying to execute is the following:
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string templatePath = Path.Combine(desktopPath, "bubble_chart.pptx");
using (Presentation presentation = new Presentation(templatePath))
{
if (presentation.Slides.Count > 0)
{
ISlide firstSlide = presentation.Slides[0];
IShape shape = firstSlide.Shapes.FirstOrDefault(s => s is IChart);
if (shape == null)
{
throw new InvalidDataException("Chart not found in slide.");
}
IChart chart = shape as IChart;
IChartData chartData = chart.ChartData;
string formula = chartData.GetRange();
chartData.SetRange(formula);
}
string fileName = Guid.NewGuid().ToString();
string fullFilePath = Path.Combine(desktopPath, $"{fileName}.pptx");
presentation.Save(fullFilePath, SaveFormat.Pptx);
Process.Start(new ProcessStartInfo(fullFilePath) { UseShellExecute = true });
}
Although there are no changes to the data or the formula, the chartData.SetRange(formula);
line throws an exception: error.png (27.7 KB)
This only happens for Bubble charts and works as intended with a single series.