Hi,
I am trying to add a series to a chart and am running into issues. I was wondering if you could give me some tips on how to get it working? I also read in the forum that chart support for XLSX files wasn"t available yet but would be in Flexcel 7. When can this be expected?
Current code snippet:
props := xls.GetObjectProperties(w, true);
procedure ProcessChart(const xls: TExcelFile; const iChart: Int32; const props: IShapeProperties; r : integer);
var
chart: IExcelChart;
childProp: IShapeProperties;
series: IChartSeries;
begin
chart := xls.GetChart(iChart, props.ObjectPath);
series.DataDefinition := "C$6$:C$"+inttostr(6+2+frmUI.SharedData.Data_Interval)+"$";
series.TitleDefinition := "Test";
chart.AddSeries(series);
end;Thanks
Hi,
This question was sent be email and newsgroups, so I will be answering only here that is where it can help more people.
About AddSeries, I see a couple of issues in your code:
1)You are assigning series.DataDefinition without creating a "series" object. This will cause an AV.
2)The syntax for absolute references in Excel is $C$6, not C$6$
3)The DataDefinition must start with an = sign to be a formula.
4)You should include the sheet also in the formula.
The final code to fix all the issues would be:
procedure ProcessChart(const xls: TExcelFile; const iChart: Int32; const props: IShapeProperties; r : integer);
var
chart: IExcelChart;
childProp: IShapeProperties;
series: IChartSeries;
begin
chart := xls.GetChart(iChart, props.ObjectPath);
series := TChartSeries_Create('Test', '=Sheet1!$C$6:$C$'+inttostr(10),
'', TCellValue.Empty, nil, nil, nil, nil, 0 ,0 ,0);
chart.AddSeries(series);
end;
And you can find an example of a working application here:
But note that whenever possible, it is much simpler to start with the maximum number of series that you will need, and then just remove the series with DeleteSeries. This way you will be able to format the series in Excel as you want them. You can use SetSeries to set the series range for each one.
About FlexCel 7, we sadly don't have an estimate time yet. I expect it will be this year, but it is still months away and it is hard to predict a date. Some weeks support is small and we advance a lot, but other weeks pass and we have just answered support email. The good news is that historically july and august are slow in support so those are months we can advance a lot, but this is not always the case either. Some years they have been very busy too.