From cfcb832434e02c935a58c6708b80b0b522d24263 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 10 Jun 2025 14:24:20 +0000 Subject: [PATCH] fpspreadsheet: Make chart skip blank cells in xlsx (instead of drawing them as zero). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9776 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/fpsexprparser.pas | 4 +++- components/fpspreadsheet/source/common/xlsxooxmlchart.pas | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpsexprparser.pas b/components/fpspreadsheet/source/common/fpsexprparser.pas index 475e5c9e4..6944543ac 100644 --- a/components/fpspreadsheet/source/common/fpsexprparser.pas +++ b/components/fpspreadsheet/source/common/fpsexprparser.pas @@ -4573,7 +4573,8 @@ end; { Is called when a formula is moved from the ASrcCell to ADestCell. Must adjust cell references which originally were relative to ASrcCell such that - they are relative to ADestCell afterwards. } + they are relative to ADestCell afterwards. + No need to move the worksheet because it is always an absolute reference. } procedure TsCellExprNode.MoveCells(ASourceCell, ADestCell: PCell); var delta: Int64; @@ -4589,6 +4590,7 @@ begin delta := Int64(ADestCell^.Col) - Int64(ASourceCell^.Col); FCol := Int64(FCol) + delta; end; + end; function TsCellExprNode.NodeType: TsResultType; diff --git a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas index 327e43b00..3264a14b1 100644 --- a/components/fpspreadsheet/source/common/xlsxooxmlchart.pas +++ b/components/fpspreadsheet/source/common/xlsxooxmlchart.pas @@ -2808,6 +2808,8 @@ var chart: TsChart; indent: String; savedRotatedAxes: Boolean; + plotVisOnly: String; + dispBlanksAs: String; begin indent := DupeString(' ', AIndent); chart := TsWorkbook(Writer.Workbook).GetChartByIndex(AChartIndex); @@ -2828,8 +2830,12 @@ begin WriteChartPlotAreaNode(AStream, AIndent + 2, chart); WriteChartLegendNode(AStream, AIndent + 2, chart.Legend); + plotVisOnly := indent + ' ' + LE; + dispBlanksAs := indent + ' ' + LE; // empty cells are not plotted + AppendToStream(AStream, - indent + ' ' + LE + + plotVisOnly + + dispBlanksAs + indent + '' + LE );