Hello Everybody,
I have a problem when I update a chart only by changing its underlying data in the embedded excel worksheet..
Basically, I create a template consisting of an empty chart and update the values by code. However, after manipulating the data points I can see them but the format changes. For example, I have a label for evey data point.
I also tried to disable the label manually but this does not work. My series variabel seems to contain 0 labels, what I find confusing, because each point shows its value, name and so on. Maybe I am missing something. Best solution would be to maintain the chart template unchanged. However, disabling all labels manually would also be fine. Can anybody help?
Best regards
Alex
PresentationEx srcPres = new PresentationEx( "myPres.pptx" ); SlideEx fstSlide = srcPres.Slides[ 0 ];
//The alternative text of the source is set as oleobject
//to get its reference quickly
ShapeExCollection sc = fstSlide.Shapes;
ShapeEx srcShape = fstSlide.FindShapeByAltText( "myShape" );
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
if( srcShape is ChartEx )
{
ChartEx chart = (ChartEx)srcShape;
if( chart != null )
{
//Getting the chart data worksheet
ChartDataCellFactory chartFact = chart.ChartData.ChartDataCellFactory;
//Take first chart series. Disable data labels (not working).
ChartSeriesEx series = chart.ChartData.Series[ 0 ];
series.Labels.ShowLegendKey = false;
series.Labels.ShowSeriesName = false;
series.Labels.ShowValue = false;
series.Labels.ShowCategoryName = false;
chartFact.GetCell( defaultWorksheetIndex, 1, 0 ).Value = "Sep'10";
chartFact.GetCell( defaultWorksheetIndex, 1, 1 ).Value = 5810;
chartFact.GetCell( defaultWorksheetIndex, 2, 0 ).Value = "Oct'10";
chartFact.GetCell( defaultWorksheetIndex, 2, 1 ).Value = 6376;
chartFact.GetCell( defaultWorksheetIndex, 3, 0 ).Value = "Nov'10";
chartFact.GetCell( defaultWorksheetIndex, 3, 1 ).Value = 6061;
chartFact.GetCell( defaultWorksheetIndex, 4, 0 ).Value = "Dec'10";
chartFact.GetCell( defaultWorksheetIndex, 4, 1 ).Value = 7385;
chartFact.GetCell( defaultWorksheetIndex, 5, 0 ).Value = "Jan'10";
chartFact.GetCell( defaultWorksheetIndex, 5, 1 ).Value = 5608;
chartFact.GetCell( defaultWorksheetIndex, 6, 0 ).Value = "Feb'10";
chartFact.GetCell( defaultWorksheetIndex, 6, 1 ).Value = 5028;
chartFact.GetCell( defaultWorksheetIndex, 7, 0 ).Value = "Mar'10";
chartFact.GetCell( defaultWorksheetIndex, 7, 1 ).Value = 6631;
chartFact.GetCell( defaultWorksheetIndex, 8, 0 ).Value = "Apr'10";
chartFact.GetCell( defaultWorksheetIndex, 8, 1 ).Value = 5756;
}
//Write the presentation on disk
srcPres.Write( "out.pptx" );