Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Oct 6, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 2 Sep 2014 at 5:44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant