I have made a template using Microsoft Powerpoint and my presentation has a pie chart.
With the help of Free Spire.Presentation I now try to fill the pie chart with data, but when saved
and opened, I get an error saying the presentation needs to be repaired.
My conclusion is that this occurs as soon as I try to change the data of the pie chart.
This is my code:
- Code: Select all
private void UpdatePieChart2(ISlide slide, int row, int col, DataRow data)
{
IChart chart = null;
Double column1 = 0;
Double column2 = 0;
for (int i = 0; i < slide.Shapes.Count; i++)
{
if (slide.Shapes[i].Name == string.Format("ChartR{0}C{1}", row, col))
{
chart = (IChart)slide.Shapes[i];
break;
}
}
if (chart != null)
{
column1 = (object)data[10] != System.DBNull.Value ? (Double)data[10] : 0;
column2 = (object)data[11] != System.DBNull.Value ? (Double)data[11] : 0;
chart.ChartData[1, 1].Value = column1;
chart.ChartData[2, 1].Value = column2 - column1;
chart.ChartData[3, 1].Value = (Double)1.0 - column2;
chart.ChartData[4, 1].Value = (Double)1.0;
}
}
Have I done anything wrong?