Project

General

Profile

Bug #121

[Google Sheets] Published HTML sheets do not display and the download button does not download.

Added by jacobk about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Low
Assignee:
Start date:
08/12/2022
Due date:
% Done:

100%

Estimated time:

Description

The document at URL https://docs.google.com/spreadsheets/d/1cnbpbQkahFou6W8atcv9Cx39-8kSjvxN5JZLvpb1b94/pub?single=true&gid=0&output=html&widget=true does not display properly and cannot be downloaded. I looked into fixing it myself, and came up with a fix that works for this document and probably other documents that only have 1 page, but it's not a very good-looking fix: https://codeberg.org/JacobK/unfinished-site-fixes/raw/commit/7b860c42038d8d5c5adb9547b19347b22d356e7e/Google%20Docs/google-sheets-fix-display.js

I started working on this a month ago and then sort of forgot about it, so I thought it would be good to open an issue here.

History

#1

Updated by koszko about 1 year ago

  • Assignee set to koszko

I'm investigating this right now. The old fix seems to work with sheet URLs that have "/edit" at the end of path.

I looked at sheet links shown by Reddit. So far I found 5 types of public sheets. They have URL paths ending with "/htmlview", "/edit", "/pubhtml", "/pubhtml/sheet" and "/pub", respectively. The first 3 seem to be commonly used, unlike the last 2. Also, manually replacing one ending with another seems NOT to work in most cases.

There is a way to tell Reddit to only show sheet links with particular URL path endings, e.g.

https://old.reddit.com/search?q=url%3Adocs.google.com%2Fspreadsheets%2Fd%2F+url%3A/pub&count=100

We could adjust the fix to work with all types. Well, your changes already cover the last 2, so it isn't that much work... although I'd still be happier if there was a way to make them all behave the same ;)

I'll try to find some simple and universal solution

EDIT: Removing "widget=true" from query parameters seems to be fixing the display issue you mentioned. If I am correct, it also removes the need to search for "pageUrl" in scripts.

#2

Updated by koszko about 1 year ago

I won't be able to finish it today but I have already found that:

  • "/pubhtml/sheet" is only for viewing a single sheet. For each such URL it seems possible to obtain a corresponding "/pub" URL with all sheets.
  • Upon exporting an editable sheet (as ods), Google includes all subsheets in it. I don't know why I couldn't seem to get it do it when I was first writing this fix about a year ago... Anyway, this means we can get rid of those single-sheet download links.
  • "/pub", "/pubhtml" and "/htmlview" need exactly the same code to make them previewable.
  • For URLs other than "/edit" we can get a download link by setting query to "?output=ods". However, I recall that I saw one sheet where it didn't work, so we'll have to check that.
#3

Updated by jacobk about 1 year ago

Upon exporting an editable sheet (as ods), Google includes all subsheets in it. I don't know why I couldn't seem to get it do it when I was first writing this fix about a year ago... Anyway, this means we can get rid of those single-sheet download links.

Doesn't this already work in the current Google Sheets fix? For example I'm able to go to https://docs.google.com/spreadsheets/d/1ydy1OVOayLgrEXu_1K9SQigYv7FJnbMJpQyOvBywNyY/edit and the current fix served by Hydrilla shows individual sheet downloads as well as a big download button. Clicking the big download button gives the entire sheet with all subsheets.

For URLs other than "/edit" we can get a download link by setting query to "?output=ods". However, I recall that I saw one sheet where it didn't work, so we'll have to check that.

It seems the link I gave as an example sheet in my original post does not download with "?output=ods", but maybe I also need to remove a specific combination of other options as well.

#4

Updated by koszko about 1 year ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

I uploaded the updated fix :)

jacobk wrote:

Upon exporting an editable sheet (as ods), Google includes all subsheets in it. I don't know why I couldn't seem to get it do it when I was first writing this fix about a year ago... Anyway, this means we can get rid of those single-sheet download links.

Doesn't this already work in the current Google Sheets fix? [...]

Yup, it does. I see no other explanation than Google changing its sheet export mechanism.

For URLs other than "/edit" we can get a download link by setting query to "?output=ods". However, I recall that I saw one sheet where it didn't work, so we'll have to check that.

It seems the link I gave as an example sheet in my original post does not download with "?output=ods", but maybe I also need to remove a specific combination of other options as well.

It seems the sheet from your link just has some specific issue that makes download impossible. It works on other "/pub" sheets, though (e.g. this one).

Unfortunately, the trick turned out not to work on "/pubhtml" and "/htmlview" sheet pages :/ I'm leaving them without a working download button for now

Also available in: Atom PDF