Navigation in published Google Sheets - google-apps-script

I need to publish a report I have in Google Sheets, but since the report is very big, with many sheets and tables, I have hyperlinks set up for easy navigation, that take you to ranges in other sheets.
When I publish the sheet, the hyperlinks stop working (they take you to the first sheet in a new browser tab). I also tried with a script to change the pages with a button, but the button is not clickable in the published page.
Thanks for any tips you might have.
EDIT:
I've prepared a test sheet to see if I find a solution for this. This is a link with permissions to edit:
https://docs.google.com/spreadsheets/d/1ZGw_6WjrkcNKdFvS8gIG46gEMfMuw7ex86SR9C7qXTU/edit?usp=sharing
And this would be the published version:
https://docs.google.com/spreadsheets/d/e/2PACX-1vTa8JDNMzwdvk87kCvbjJXYgK2RGiKy503eJn6eEjxbyU8oIsuvuKTNXCM6yRP16KXrnD9yvLV3J488/pubhtml
This actually works in Excel, I can embed the report and the hyperlinks still work fine, but I have everything else in Google Sheets, so I'd like to find a workaround.

You need to use proper query parameters. The sheet id, gid must be set to navigate properly. You cannot use rangeid. You can however use range.
/pubhtml?chrome=false&gid=[YOUR_SHEET_ID]&range=A1:B1
You can get your sheet id by visiting your sheet(tab) in your spreadsheet (edit version) and inspecting the url.

Your published sheet probably retains the original #gid (which is Google's sheet ID used for local links). This will fail because it is linked to a Spreadsheet that is inaccessible to the new report. Please check if this is the case (you'll see in the links you've created). I can understand that you won't want to share the original reports but you can set up a small test Spreadsheet with a few linked sheet ranges to test the process - please share that.

Related

How do I delete a container-bound script when a Google Sheet is pointing to multiple?

I have been put in charge to automate several Google Sheets for different teams throughout our organization.
It started out with 1 main template. Easy enough.
That template is copied each time a new project comes in.
Eventually a second template was born off of the original (the original is still used as well though)
Some changes were made to the UI of the sheet and I added additional automation based off of the new columns. All seemed well.
As of last week, when I go to the Script Editor of a sheet I get this window:
Let's say I select the first option. If I edit it and test the code, it doesn't work as expected because it's still pulling from the other 2 scripts!
I don't know when or how this happened.
How can I fix this?
You can manage you script by going to: Google Scripts

Recording any copies made of a google sheet

I would like to create a Google sheet that records any copies that have been made of another Google Sheet even when the user creates a copy by putting 'copy' into the URL (https://docs.google.com/spreadsheets/d/"spreadsheet-ID"/copy).
I have found a solution on the post: Track number of copies made from a google spreadsheet but this doesn't record copies made when changing the URL as the above example.
I would like to know the whole URL of the sheet preferably but just the Spreadhseet ID would still be enough for me.
Has anyone got any ideas how I can record all this data onto a spreadsheet please?
Basically you won't have access to see who is copying your sheet if you use the built-in Make Copy.
What you could do is integrate part of the question you have provided, while disabling the built-in sharing method. So the only way to copy your sheet could be through a custom function you can control and register every time it executes.

Sync Google Sheets with Web Page HTML

What is the easiest way I can sync a sync a google sheet with a web page form (see attached picture)? Ideally an example code or tutorial.
Here is what I want: I want users to access my web page so they can select their name from a drop-down menu and put it next to the item they wish. Then once they click submit, each person's name value will be transferred from the webpage and then recorded into the corresponding cell inside the google spreadsheet. Then when the next user comes to the site, the fields will auto-populate from the google sheet so he will see who has picked what and what choices are left.
Ideally I would just send the users directly to the google sheet to make their selections, however, they can't edit it on a mobile phone without d/l the app and a bunch of other bogus roadblocks. Google Forms also does not work for this for several reasons.
Some things to keep in mind:
- the spreadsheet is totally public and editable. So I'm hoping to avoid the need to set up an API
- no security or login necessary for the users (I am not worried about if someone changes someone else's name)
I have spent weeks trying to find how to do this but I'm just a construction worker I don't know technology
SYNCING HTML FORM WITH GOOGLE SHEET
From Tanaike,
If you can use the web page as Web Apps of Google, I think that it can achieve what
you want using Google Apps Script, and you can get and put the values
of Spreadsheet. In this case, the Spreadsheet is not required to be
published. The document of Web Apps is [can be found in comments].
– Tanaike 10/19/2018

Use a Google Docs Spreadsheet as a datasource for a dynamic Google Sites webpage

I have a Google Form that feeds a Google Docs Spreadsheet. I'd like to--in turn--have that Google Docs Spreadsheet feed a webpage.
In plainer English, babysitters fill out the form to sign up to be in our community's Babysitter Directory. The spreadsheet houses all of the data. I'd like to code a webpage to pull selected bits of the data for the online directory.
I've tried doing a separate sheet in the spreadsheet, using a QUERY to select the columns that I want to include (and the order in which I want to include them), publishing that sheet to the web, then embedding that sheet into the webpage in an iFrame. And that works.
But even with the QUERY, there are SO many columns that users need to scroll WAY over to the right to see all the data for each babysitter. It's unwieldy.
What would be way better would be if I could break the data for each entry over multiple lines and do some nice formatting for a directory, rather than just a linear spreadsheet. So that, essentially, each babysitter's "entry" in the directory is more than 1 line long. Does that make sense?
If I was working in Office, I would know exactly what to do: use the Excel spreadsheet as the datasource for a Word Mail Merge and I would put move the fields around on the page to make it all look good.
And, to be sure, if I can do this in a Google Doc, then embed the Doc into the webpage, that's fine, too. But I would think there's some way I can do it directly in the Google Site?
Can I?
If anybody has even just a reference page for me to take a look at, I'd appreciate it.
Thanks!
Are you trying to do this in Google Sites? If so, you can embed the entire spreadsheet on the page, but if you only want certain columns, you can try inserting an Apps Script widget on the page.
You need to know how to write a Google Apps Script that will run JS functions and render HTML, here is a tutorial
To create the Script that can run on your page, go to:
More > Manage site > Apps Script > Add new script
Here's also a link to how to interact with Spreadsheet data.
What you want to do is more or less a database interface that uses a spreadsheet as 'data holder', depending on your programming skills it can be quite easy or very hard...
Here is an example of such a webapp, its has probably too many fields and features but the general idea is the same (a quick search tool and a window to show results).
It that what you had in mind ?
If so I can share the code to help you to get started but if you are not familiar with javascript it will probably need too much effort to get through.

Google Apps Script To Help Error When Embedding Google Spreadsheet in a Google Site?

Spreadsheet A is the master data source for the group that welcomes Newcomers to our little town. It has a ton of very sensitive data in it and cannot be public, not even a little bit. (We're talking about names and birth dates of kids and where they go to school . . . keeping Spreadsheet A secure is mission critical.)
So, Spreadsheet B uses an importRange and a query to pull the necessary columns from Spreadsheet A to populate our "Member Directory".
Then, I embedded Spreadsheet B in the group's Google Site. (Feel free to check out the site if you like at www.SewickleyNewcomers.com )
And it works beautifully.
BUT . . . after I shut Spreadsheets A & B down and a few hours go by, if I try to open the webpage that has the Member Directory embedded in it, the embedded sheet says "#VALUE!"
When I then go and open Spreadsheet B again, it says the same thing: "#VALUE!".
UNTIL, I let Spreadsheet B sit for a few minutes. Then, after it's sat for a few minutes, all of a sudden, all of the data populates again.
AND if I go back to the webpage with the Member Directory embedded in it, all's good.
Presumably, the problem is that if Spreadsheet B is not open, it can't pull the data from Spreadsheet A.
But I can't embed Spreadsheet A because there are columns and sheets that cannot be publicly accessible, as mentioned above.
Some details:
Both Spreadsheet A and Spreadsheet B are currently set to "Anyone with the link" as the sharing preference. (Although I'd ideally like to get Spreadsheet A back to "Private".)
Spreadsheet B is embedded in the Google Site with the built-in Insert Spreadsheet Widget.
Here's the formula I'm currently using to pull the data from Spreadsheet A to Spreadsheet B:
=arrayformula(query(importrange("_","Master!A:Z"), "select Col3, Col2, Col22, Col18, Col19, Col20, Col21, Col24 where Col26='Yes, go ahead and include my contact information in the online directory and in the print directory.' and (Col4='Yes' or Col4='yes') order by Col3"))
Anybody have any thoughts about what's going on here? And ideas for other ways I can get the necessary data out of Spreadsheet A and onto the site (I certainly don't have to go through Spreadsheet B, I just couldn't think of another way to keep all the other data on Spreadsheet A private)? Is there a solution that uses some kind of Apps Script on the Google Site to end-run needing to embed the spreadsheet?
Thanks in advance! And all the people who move to Sewickley thank you, too!
importRange shows what it is expected to show 85% of the time (according to my experiments).
During the other 15%, it shows #N/A or #VALUE.
I believe that if, having found #VALUE on the web page, you just wait a lot (10-15 minutes), then the correct data will come back to the web page, even if you do not reopen the spreadsheets.
Anyway, to avoid this problem, you can make a worksheet "publicSheet" within the master spreadhseet A,
fill it with formulas that copy necessary things from the other worksheets,
and publish this particular worksheet by File>Publish to the web>"publicSheet".
If you do so, still nobody can access the other worksheets of the spreadsheet A,
but the data will never disappear from the published worksheet.