GNOME Bugzilla – Bug 694408
ssconvert -S exports multiple copies of first sheet
Last modified: 2018-05-10 18:18:32 UTC
Given a file Book1.gnumeric with two sheets, the command ssconvert -S Book1.gnumeric Book1.txt creates, as expected, 2 files Book1.txt.0 and Book1.txt.2 but both files contain the information from the first sheet. This is http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699751
The logic in there (ssconvert.c:738) is pear-shaped. It works for .cvs, for example. I am guessing that for .xls you get N copies of the same file.
Well, in Gnumeric, when we export to csv, the exporter exports only the current sheet; when we export to text we can choose the sheets to export. ssconvert -S just changes the current sheet and calls the exporter, so i guess the default in the configurable exporter is just not correct.
I see the problem: Breakpoint 1, gnm_stf_file_saver_save (fs=0x8064db0, context=0x80c1578, view=0xb5a23808, output=0xb5a25018) at stf-export.c:680 680 if (!stfe->sheet_list) (gdb) p stfe->sheet_list $1 = (GSList *) 0x0 (gdb) c Continuing. Breakpoint 1, gnm_stf_file_saver_save (fs=0x8064db0, context=0x80c15d0, view=0xb5a23808, output=0xb5a250c8) at stf-export.c:680 680 if (!stfe->sheet_list) (gdb) p stfe->sheet_list $2 = (GSList *) 0x80d31d0 (gdb) For the first sheet we don't have an existing stfe->sheet_list so the current sheet is added. When we run the exporter the second time (supposedly for the second sheet), the sheet_list already exists and so we do not add the current sheet.
We have three situations: * single-sheet exporters like cvs. This is what the code was meant for. * multi-sheet exporters with sheet selector. Just .txt, really. Neither this code nor the sheet selection was meant to be used for this. In fact, one could set the list of sheets using the right export options, so I don't think we can use that list for anything other than the list of sheets to export. * multi-sheet exporters without sheet selector. This is .xls and .gnumeric The code really wasn't meant for this, but it is not an unreasonable thing to do.
A proper fix for this is going to be 1.13 stuff, but we can probably hack some bandaid up in the meantime. wb_view_save_as and similar are going to need an option object. The GOffice base class for this should probably be pretty much empty. The Gnumeric base class for this should probably have a sheet list and not a whole lot more.
This problem is very well demonstrated in the corresponding Debian bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699751#20
*** Bug 711868 has been marked as a duplicate of this bug. ***
Fixed for .txt, i.e., basically all single-sheet exporters. All the multi- sheet exporters will happily will put all sheets into every file. (And, given how this was hacked, the sheet order will be wrong in all but the first output file.)
First of all, thanks for the amazing job you done for free. I am about to use ssconvert in a PHP project, but I am concerned why an aged discovered bug, which I also encountered with, is not yet fiexed. Is there going to be a fix at all? Is the project still under development? Or should I use an alternative solution?
From comment 8: "Fixed for .txt, i.e., basically all single-sheet exporters." So it is mostly fixed. It will, eventually, get fully fixed when someone who has the inclination and time does it.
Thanks for the time and effort. You are amazing.
This problem has been fixed in our software repository. The fix will go into the next software release. Once that release is available, you may want to check for a software upgrade provided by your Linux distribution.