GNOME Bugzilla – Bug 690203
incorrect saving of this .xslx file
Last modified: 2012-12-18 23:46:06 UTC
Created attachment 231564 [details] .xslx file to reproduce the problem When opening this file which has been created by gnumeric, an error message appears.
I don't see any error message when loading that file with current git. What message and what version of Gnumeric are we talking about?
According to the file content, the attached file was _not_ created by Gnumeric but by Microsoft Excel (version 12.0000): in /docprops/app.xml: <Application>Microsoft Excel</Application><AppVersion>12.0000</AppVersion>
Created attachment 231574 [details] .xslx file to reproduce the problem
With the file of comment #3 I see on the console: (gnumeric:6984): XML-CRITICAL **: Document is empty (gnumeric:6984): XML-CRITICAL **: Start tag expected, '<' not found and get the error message: Part 'rId1' in 'chart1.xml' from 'drawing1.xml' is corrupt! looking in the package shows that 'chart1.xml' is indeed empty. Frederic, please provide the .gnumeric file that was saved as the .xlsx file of comment #3. My initial guess is that we either did not implement export of a certain chart type to xlsx. We either did not get around to it yet or the xlsx file format does not support the chart type in question. In the former case we should implement it, in the latter we should save some sort of chart to avoid the errors on rreading (and of course warn on saving).
Unfortunately, I don't have the corresponding .gnumeric file. If I remember correctly, the graph was an XY graph with two series, maybe with staircase lines conecting points.
It looks to me as if the chart contained two plots since the drawing1.xml refers to two charts chart1.xml and chart2.xml. The second one contains the scatterplot. The problem clearly happened during export, so without the example file containing the information that was not exported, it is pretty much impossible to determine what caused the chart1.xml file to be empty.
Created attachment 231585 [details] sample gnumeric file saving the attached gnumeric file as an .xlsx file and then opening the xlsx file in Gnumeric results in the errors mentioned above. In this case the chart ends up containing no plot, not even the scatter plot. The Gnumeric file contains a PlotDropBar that is the root cause of the problem in this case.
in xlsx-write-drawing.c we have: static void xlsx_write_chart (XLSXWriteState *state, GsfOutput *chart_part, SheetObject *so) { (...) graph = sheet_object_graph_get_gog (so); if (NULL == graph) return; chart = gog_object_get_child_by_name (GOG_OBJECT (graph), "Chart"); if (NULL == chart) return; plot = gog_object_get_child_by_name (GOG_OBJECT (chart), "Plot"); if (NULL == plot) return; For the .gnumeric file of the previous comment (NULL == plot) is true and so we write no plots at all.
Exporting charts to .xslx is unreliable for now. Even worse than exporting to .xls
Created attachment 231659 [details] [review] propsed minimal patch Minimal patch to avoid creating files that we complain about. This patch simply drops the second and later plot in a chart we want to export to xlsx. At least it does not drop all plots whenever there is more than one. Not yet committed since we are in code freeze.
Why are you changing the silent returns to g_return_if_fail? (For null graph or chart.)
Those returns are a problem, In fact we should probably complain about a return on NULL plots too: Whenever we return we don't write content to the corresponding graph.xml, and later complain about it when we try to open the file.. Can those be NULL for a sensible chart object?
If you create a gnumeric file, insert a graph but delete all plots or all charts from that graph and then save the file as an xlsx file, then with or without the patch of comment #10 you obtain a file that Gnumeric complaints about when opening. With the patch of comment #10 you get a warning on the console as you save the file.
Created attachment 231690 [details] [review] more elaborate patch This patch handles sheet objects with no plots or charts and still creates a file Gnumeric accepts without complaint. The files are also accepted by LibreOffice, but I have yet to test MS Excel.
I think if would be good to commit this, although for this part: + if (n == 1) + g_warning ("Dropping a plot from a chart.", n); + else + g_warning ("Dropping %d plots from a chart.", n); there really is no need to be (US) grammatically correct in error messages. Just do the plural.
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.