0
votes

I know it's possible to display a Google Sheet as HTML using the spreadsheet ID and GID, i.e.:

https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/gviz/tq?tqx=out:html&tq&gid=GID

But in order to view that, you have to know the URL of the sheet. What I'm wondering is whether it's possible to display this HTML version of the sheet but without revealing the URL of the sheet?

1
I cannot understand about display this HTML version of the sheet but without revealing the URL of the sheet. I apologize for this. In order to correctly understand about your goal, can I ask you about the detail of your goal?Tanaike
I want to be able to display a Google sheet in a web page (i.e. HTML) but not reveal the location of the sheet (so that it's not possible to view the source of the web page and get the URL of the sheet)user2724502

1 Answers

0
votes

Manually

To retrieve a Spreadsheet in HTML format you can export it accordingly by clicking on File -> Download -> Web Page. That will get you a zip file with the HTML of your Spreadsheet that you can rename as you like without revealing the Spreadsheet ID.

With Apps Script

You can also automate this process creating an Apps Script function that for instance gets triggered every time you click on an inserted button (to do this you can simply click on the menu bar Insert -> Drawing and the on the three dots of the top right of this button click on assign script and set it to the name of your function).

The following function will display a modal dialog on the Spreadsheet when run that if the user clicks on Download it will automatically download the zip file with the Spreadsheet in HMTL format. This function has self explanatory comments :

function downloadHTML() {
  // Get ID of the Spreadsheet
  var id = SpreadsheetApp.getActive().getId();
  // Get the download URL of this Spreadshet in format HTML on the background 
  var url = "https://docs.google.com/a/mydomain.org/spreadsheets/d/" + id + "/export?exportFormat=zip&access_token=" + ScriptApp.getOAuthToken();
  // Download when clicked on the button of the opened dialog
  var html = '<input type="button" value="Download" onClick="location.href=\'' + url + '\'" >';

  // create an HTML output from the given string
  var dialog = HtmlService.createHtmlOutput(html);

  // Show a modal dialog on the Spreadsheet UI when the function is run with the Title download
  SpreadsheetApp.getUi().showModalDialog(dialog, "Download");
}

Reference