I'm currently generating Excel-documents using the Office Object Model. I have a problem with editing charts. In a template file I got a bar-chart which uses the following source:
2008 2009 2010
A 10% 25% 15%
B 20% 25% 35%
C 30% 25% 45%
D 40% 25% 5%
The chart has the following formula: =sheet2!$A$1:$D$5
When for example the column '2009' is empty, I don't want to show the bar in the chart. So I want to change the formula to something like: =sheet2!A$1:D$5;sheet2!C$1:C$5
I know there is a method setSourceData, but I need to get the current formula or range first.
My question is; How can I get the chart formula? Or maybe there is another way to do what I want?
I also tried something with dynamic ranges in Excel, but this seems to only work with columns that are added or removed from the end of the range, not in the middle like column '2009'.