After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 690203 - incorrect saving of this .xslx file
incorrect saving of this .xslx file
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export MS Excel (tm)
git master
Other All
: Normal major
: ---
Assigned To: Andreas J. Guelzow
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2012-12-14 11:22 UTC by Frédéric Parrenin
Modified: 2012-12-18 23:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
.xslx file to reproduce the problem (19.17 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-12-14 11:22 UTC, Frédéric Parrenin
  Details
.xslx file to reproduce the problem (546.39 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-12-14 16:46 UTC, Frédéric Parrenin
  Details
sample gnumeric file (2.73 KB, application/x-gnumeric)
2012-12-14 19:19 UTC, Andreas J. Guelzow
  Details
propsed minimal patch (1.44 KB, patch)
2012-12-16 17:10 UTC, Andreas J. Guelzow
none Details | Review
more elaborate patch (4.35 KB, patch)
2012-12-17 01:12 UTC, Andreas J. Guelzow
none Details | Review

Description Frédéric Parrenin 2012-12-14 11:22:11 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.
Comment 1 Morten Welinder 2012-12-14 14:47:38 UTC
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?
Comment 2 Andreas J. Guelzow 2012-12-14 16:35:28 UTC
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>
Comment 3 Frédéric Parrenin 2012-12-14 16:46:47 UTC
Created attachment 231574 [details]
.xslx file to reproduce the problem
Comment 4 Andreas J. Guelzow 2012-12-14 17:35:15 UTC
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).
Comment 5 Frédéric Parrenin 2012-12-14 17:46:29 UTC
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.
Comment 6 Andreas J. Guelzow 2012-12-14 18:15:26 UTC
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.
Comment 7 Andreas J. Guelzow 2012-12-14 19:19:39 UTC
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.
Comment 8 Andreas J. Guelzow 2012-12-14 20:16:56 UTC
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.
Comment 9 Jean Bréfort 2012-12-15 19:46:31 UTC
Exporting charts to .xslx is unreliable for now. Even worse than exporting to .xls
Comment 10 Andreas J. Guelzow 2012-12-16 17:10:32 UTC
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.
Comment 11 Morten Welinder 2012-12-16 17:50:43 UTC
Why are you changing the silent returns to g_return_if_fail?
(For null graph or chart.)
Comment 12 Andreas J. Guelzow 2012-12-16 23:52:16 UTC
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?
Comment 13 Andreas J. Guelzow 2012-12-17 01:09:51 UTC
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.
Comment 14 Andreas J. Guelzow 2012-12-17 01:12:08 UTC
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.
Comment 15 Morten Welinder 2012-12-17 23:22:14 UTC
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.
Comment 16 Morten Welinder 2012-12-18 23:46:06 UTC
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.