Skip to content

Commit

Permalink
[FIX] xlsx: ignore charts without data set
Browse files Browse the repository at this point in the history
When we parse the XML and extract the data sets, we expect an element
`c:val`. But this element is optional according to the spec.

It leads to a chart with a `dataSets` property being an empty array.
It crashes (17.0) or the chart is ignored (18.0) later down the line
because a chart without any data set makes no sense.

I must admit I do not fully understand what are those charts without
data set in excel. When importing the file in Excel Online or Google
Sheet, there's no chart...

With this commit, we ignore those charts as well.

closes #5427

Opw: 4443811
Task: 4460515
X-original-commit: fedb344
Signed-off-by: Rémi Rahir (rar) <[email protected]>
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
  • Loading branch information
LucasLefevre committed Jan 8, 2025
1 parent 0b78315 commit 92b29c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/xlsx/conversion/figure_conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function convertFigure(
}

function isChartData(data: ExcelChartDefinition | ExcelImage): data is ExcelChartDefinition {
return "dataSets" in data;
return "dataSets" in data && data.dataSets.length > 0;
}

function isImageData(data: ExcelChartDefinition | ExcelImage): data is ExcelImage {
Expand Down

0 comments on commit 92b29c1

Please sign in to comment.