FPSpreadsheet: Prevent Excel read error when a chart contains no series.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9444 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
dc76d5d993
commit
3d203a2dc4
@ -6618,6 +6618,12 @@ procedure TsSpreadOOXMLWriter.WriteDrawings(AWorksheet: TsBasicWorksheet);
|
|||||||
sheet: TsWorksheet;
|
sheet: TsWorksheet;
|
||||||
guid: TGUID;
|
guid: TGUID;
|
||||||
begin
|
begin
|
||||||
|
// When a chart contains no series Excel writes a completely different
|
||||||
|
// node for the chart, otherwise reading of the file crashes.
|
||||||
|
// --> Do not write an empty chart in our way at all.
|
||||||
|
if AChart.Series.Count = 0 then
|
||||||
|
exit;
|
||||||
|
|
||||||
r1 := AChart.Row;
|
r1 := AChart.Row;
|
||||||
c1 := AChart.Col;
|
c1 := AChart.Col;
|
||||||
rOffs1 := AChart.OffsetY;
|
rOffs1 := AChart.OffsetY;
|
||||||
|
|||||||
@ -4270,13 +4270,11 @@ procedure TsSpreadOOXMLChartWriter.WriteChartPlotAreaNode(AStream: TStream;
|
|||||||
var
|
var
|
||||||
indent: String;
|
indent: String;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
ser: TsChartSeries;
|
xAxKind, yAxKind, x2AxKind: String;
|
||||||
xAxKind: String = 'c:catAx';
|
|
||||||
yAxKind: String = 'c:valAx';
|
|
||||||
x2AxKind: String;
|
|
||||||
hasSecondaryAxis: Boolean = false;
|
hasSecondaryAxis: Boolean = false;
|
||||||
begin
|
begin
|
||||||
indent := DupeString(' ', AIndent);
|
indent := DupeString(' ', AIndent);
|
||||||
|
|
||||||
FAxisID[caaBottom] := Random(MaxInt);
|
FAxisID[caaBottom] := Random(MaxInt);
|
||||||
FAxisID[caaLeft] := Random(MaxInt);
|
FAxisID[caaLeft] := Random(MaxInt);
|
||||||
FAxisID[caaRight] := Random(MaxInt);
|
FAxisID[caaRight] := Random(MaxInt);
|
||||||
@ -4287,14 +4285,11 @@ begin
|
|||||||
indent + '<c:plotArea>' + LE
|
indent + '<c:plotArea>' + LE
|
||||||
);
|
);
|
||||||
|
|
||||||
if AChart.Series.Count > 0 then
|
// Write series attached to primary y axis
|
||||||
begin
|
WriteChartSeries(AStream, AIndent + 2, AChart, calPrimary, xAxKind);
|
||||||
// Write series attached to primary y axis
|
|
||||||
WriteChartSeries(AStream, AIndent + 2, AChart, calPrimary, xAxKind);
|
|
||||||
|
|
||||||
// Write series attached to secondary y axis
|
// Write series attached to secondary y axis
|
||||||
hasSecondaryAxis := WriteChartSeries(AStream, AIndent + 2, AChart, calSecondary, x2AxKind);
|
hasSecondaryAxis := WriteChartSeries(AStream, AIndent + 2, AChart, calSecondary, x2AxKind);
|
||||||
end;
|
|
||||||
|
|
||||||
// Write the x and y axes. No axes for pie series and related.
|
// Write the x and y axes. No axes for pie series and related.
|
||||||
if not (AChart.GetChartType in [ctPie, ctRing]) then
|
if not (AChart.GetChartType in [ctPie, ctRing]) then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user