Question

I'm making an application, that downloads data and generates PowerPoint presentation out out of it. I managed to get create a chart and access the data like this:

Microsoft.Office.Interop.PowerPoint.Shape Shape;
Microsoft.Office.Interop.Graph.Chart Ch;

Shape = Slide.Shapes.AddOLEObject(
                    Bounds.Left, Bounds.Top,
                    Bounds.Width, Bounds.Height,
                    ClassName);
Ch = (Graph.Chart) Shape.OLEFormat.Object;
Ch.Application.DataSheet.Cells[1, 2] = "some value";

But the data source is still the default 5x4 cells area. How can I change it? I searched for a while and saw things like .Set_DataSource(), but I don't have anything like that.

Was it helpful?

Solution

Apparently this generates the kind of chart used in the older versions of PowerPoint and the data area auto-grows there. I mostly tried to shrink the datatable and I already tried setting the cell values to null or "" and it didn't work, that's why I couldn't figure it out. Anyway, the solution was to clear the DataSheet:

Ch.Application.DataSheet.Rows.Clear();

(I found this by chance through browsing the intellisense.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top