HsnMustafa / gdocbackup

Automatically exported from code.google.com/p/gdocbackup
0 stars 0 forks source link

New (2014) spreadsheets will fail to download as xls (Excel) - source workaround included #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Short version
=============

- Google Drive's "new Sheets" won't download as xls in GDocBackup.

- The quickest fix is to grab the source, apply the following workaround, build 
it*, and use that.

- Hopefully the developer/owner (Fabrizio) will take a look at this workaround 
and integrate it in to the official build somehow, making things easier for 
future users. :)

- Hacky workaround:

In GDocBackupLib/Backup.cs, change line 444 from:

gdocStream = request.Download(doc, downloadtype.ToString());

to:

gdocStream = request.Download(doc, "xlsx");

- That's it. Hope this helps someone!

* (there are a couple of steps to building this from source, but I won't go 
over them here, as they're not specific to this issue).

Long version
============

In the latest version of GDocBackup (0.7.6.187), "new Sheets" (the default in 
Drive as of March/April 2014) will fail to download in Excel format. (All the 
other format options in GDocBackup seem to work fine.)

I think I've finally managed to isolate the issue.

Reproduce
---------

1. Create a new sheet in Drive. 
2. Add some content, name it, etc.
3. Launch GDocBackup, make sure "Export format" for "Spreadsheet" is set to 
"xls" (or, if "Enable multi-export" is checked, that "xls" is checked in the 
column for "Spreadsheet").
4. Exec.

Expected
--------

- "New Sheets" download as Excel-format files.

Result
------

- GDocBackup reports "ERROR".
- The log reports:

DOC-ERROR: (attempt 0) Google.GData.Client.GDataRequestException: Execution of 
request failed: 
https://docs.google.com/spreadsheets/export?id=[key]&exportFormat=xls ---> 
System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Google.GData.Client.GDataRequest.Execute()
   --- End of inner exception stack trace ---
   at Google.GData.Client.GDataRequest.Execute()
   at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
   at Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince, String etag, Int64& contentLength)
   at Google.GData.Client.Service.Query(Uri queryUri)
   at Google.Documents.DocumentsRequest.Download(Document document, String exportFormat)
   at GDocBackupLib.Backup.ExecBackupSingleUser(String username) in c:\[...]\GDocBackupLib\Backup.cs:line 444

Workaround
----------

In GDocBackupLib\Backup.cs, make the following change, from:

442:  else if (doc.Type == Document.DocumentType.Spreadsheet)
443:  {
444:      gdocStream = request.Download(doc, downloadtype.ToString());
445:  }

to:

442:  else if (doc.Type == Document.DocumentType.Spreadsheet)
443:  {
444:      gdocStream = request.Download(doc, "xlsx");
445:  }

(Note that only line 444 is changing.)

It should work for new AND old Sheets.

Be warned, however: I don't know how robust this workaround is. YMMV! Give it a 
good test before you merrily hit "Exec" and somehow wipe your startup's 4,000 
irreplaceable spreadsheets. :)

Notes
-----

- I was pretty surprised that this worked at all, but having tested it a few 
ways, it seems fine.

- I've got a feeling that the problem here is ultimately on Google's end. 
Having searched, I can't find a report that seems to get this specific, so I'll 
try and report it to them if I get the time.

- Thanks Fabrizio for this great tool!

Original issue reported on code.google.com by jas...@gmail.com on 2 Sep 2014 at 5:44

GoogleCodeExporter commented 9 years ago
Oops. This issue partially duplicates some stuff from issue 111: 
https://code.google.com/p/gdocbackup/issues/detail?id=111

Original comment by jas...@gmail.com on 2 Sep 2014 at 5:53

GoogleCodeExporter commented 9 years ago

Original comment by fht...@gmail.com on 2 Sep 2014 at 8:40

GoogleCodeExporter commented 9 years ago
Just published a BETA with the fix. Try it and let me know if it works.
https://drive.google.com/folderview?id=0B9kSHSg5lGq4dDRsQ3lUVTdmaGM&usp=sharing

Original comment by fht...@gmail.com on 15 Oct 2014 at 6:35

GoogleCodeExporter commented 9 years ago
I installed the BETA and it appears to only have the xls file formats which 
duplicates all of my newer spreadsheets.  MS Excel also give me an error 
stating that "The file you are trying to open, "filename.xls", is in a 
different format than specified by the file extension.  Verify that the file is 
not corrupted and is from a trusted source before opening the file.  Do you 
want to open the file now?  Yes, No, Help"  If I select yes it opens file.  If 
I change the extension to xlsx the file opens without the warning.

Original comment by 5pm1...@gmail.com on 8 Jan 2015 at 5:05