I am working on a google spreadsheet for my team members where they can save their logs so I have made a separate sheet for each of them but I do not want to let them see each others logs due to some privacy reasons.
I am hiding sheets with the app script and associated them with the email address of the users. But when any user opens his/her sheet then it works just fine, but if other users open their sheets then it get messed up.
If user A open A1 rest other sheets are hidden, but when user B opens B1 then it gets rendered to user A also. I can't understand if its because the google spreadsheet has only one instance or its some fault in my code.
Unfortunately your approach is not feasible
As you suspected, the google spreadsheet has only one instance.
So if one user performs any change on the visibility of a sheet, this change will be also visible to all other users that work on the same spreadsheet.
As a workaround, you can create a separate spreadsheet for each user that cannot be accessed by other users.
Those spreadsheets can be synced to a common master spreadsheet that can be seen and edited by you.
You can do this sync with a simple =IMPORTRANGE() formula.
Related
Thanks - I'm learning because of you
Thanks to the great posts and comments on stackoverflow, I've learned so many ways to enhance my use of Google Ads (my primary role) via the JavaScript-like Apps Script and now I've moved on to integrating with Google Sheets. Bravo stackoverflowers for your commitment to helping others!
Question
Is there any way to trigger a script attached to a Google Sheets document that would fire on hovering? We have a spreadsheet that contains tabs for the current month's online advertising budgets for a client by month. We duplicate the previous month's tab rather than just adding a column to the existing (previous month) tab because we sometimes added notes in a merged set of cells before we discovered how easy a popup HTML window could be implemented.
I cannot find anything in the scripts guides or via Google searches, but I am using a button that is prominent (just an inserted drawing attached to a script) that can be clicked to pop up an HTML file that explains the documents overall purpose.
Ideally, there would be something that displayed when hovering over a cell or button, but we could also live with something where a popup "speech bubble" would display on the entering of a cell.
Unfortunately, as we all know, there is no "onFocus" event.
With that in mind, are there any options that might accommodate hover, entering a cell but not changing the values, etc? Anything that might allow for tooltips, popups or other guidance to someone reviewing a spreadsheet without an accompanying text document.
Thanks in advance for reading - I've included a screenshot of the way I've currently implemented a per-sheet button that provides notes on specific changes for that tab.
Short answer: There aren't hover-like triggers but you could use notes or comments for showing a text related to a cell.
The docs about triggers are
https://developers.google.com/apps-script/guides/triggers
https://developers.google.com/apps-script/guides/triggers/installable
An the related event objects are listed in
https://developers.google.com/apps-script/guides/triggers/events
Here is how a cell with a "hidden" note looks
Here is how a cell and a displayed note looks
Cell notes could be inserted from the UI and by using Google Apps Script, i.e. setNote(note)
Related
Google Apps Script Spreadsheet Comment Automation
One nice feature of Google sheets is that two users can use the sheet at once.
If I am editing the sheet myself, using Google App Scripts (GAS) an onEdit event is fired when I make a change to a cell.
If I have the sheet open by two different users, is there a way to detect a change made by someone else? I would like to keep the Google app script code up to date without having to constantly poll the sheet to check if anyone else has made an amendment.
I have the following as my onEdit code, this puts up a simple alert when something is edited.
function onEdit(){
var ui = SpreadsheetApp.getUi();
ui.alert('Edited');
}
This fires only on the user that made the change and not the other user looking at the spreadsheet.
Thanks in advance.
--> I'm getting iframe code to embed in microsoft excel. But I can see the sheet only in the web page.
--> I want to edit the embedded sheet and I want to add a button to upload that embedded sheet into test link database.
Can anyone please help me? Is there any plugin to do it?
Method 1. You can create a google spreadsheet and there is an option to publish it to web and get the embed code for iframe. The iframe code can now be used in any webpage. The sheet will get displayed in the webpage but you wont be able to edit the cells.
Method 2. You can create a google spreadsheet. You can directly use the spreadsheet url (eg: https://docs.google.com/spreadsheets/d/1jTvLJsqOVOnmCrNCCqoUs9vRJkYrD_kJRLyY/edit#gid=0) which you see in your browser's address bar and use it as the src to iframe in your webpage. The spreadsheet will get displayed in your webpage and you can also edit the cells in it. Thanks to the x-frame-options header which google has not applied/checked.
Sync Data between Sheet and DB:
You can write a macro code/ Google Script function which will get triggered/ executed on various events such as sheet open, row edited, button clicked etc. In the code you can create a JDBC connection to your database such as MYSQL, MSSQL, Mongo etc and sync the rows as per your logic. https://developers.google.com/apps-script/
You can also use plugins such as Zapier, Kloud.io etc to sync the data (Bidirectional) between the sheet and your preferred DB.
I have a google spreadsheet that stores data at my work and is constantly being updated via google drive so it is always online editing, what I want to do is to be able to extract the values in those cells and have them show up in a HTML5 table on my website, what would be the best solution for this?
I did try one way which was to just embed the spreadsheet in a iFrame and have that refresh every 5 minutes, but the refresh loading is too slow and it causes issues with trying to get the spreadsheet to fit perfectly in the iframe everytime I refresh. these websites will be on display on TV screens so I dont want to be adjusting them regularly, they will auto refresh and be idle.
Your Google Sheet's rows/columns can be exported as a pretty minimal HTML table. You can grab that HTML and manipulate it however you like. Here's how to get it:
Open the Sheet and find your file_id in the URL, and the gid for the specific tab you wish to export (you may have several spreadsheets within a single Google Sheet).
Use this URL string, replacing <FILE_ID> and <TAB_GID> with your own:
https://docs.google.com/spreadsheets/d/<FILE_ID>/gviz/tq?tqx=out:html&tq&gid=<TAB_GID>
You can set the refresh/recalculation rate under File > Spreadsheet settings to be every minute, if necessary.
Example:
Here is a Google Sheet with some data. To export this as an HTML table, we take:
the file_id: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms and
the tab_gid: 0
from the URL and substitute those into the URL string (above), yielding:
https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/gviz/tq?tqx=out:html&tq&gid=0
Hope that helps. 🍻
I'm currently working on a Google Spreadsheet that has to include a bunch of image references.
What I want to achieve is this: When you hover over a cell an image appear (like a tooltip).
I found this widget on the Google Developers, but when I add the code to my spreadsheet nothing happens.
Does any of you guys know how to do something like this? Any hints on how to go about this is highly appreciated!
Displaying a User Interface from a Spreadsheet
As an alternative to deploying your user interface as a standalone web app, you can create a container-bound script from a Spreadsheet, and display the user interface from the Spreadsheet. To do this, find your doGet function and simply replace the call to
return app;
with the following:
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
spreadsheet.show(app);
where app is the variable name for the UiInstance object you are returning. Additionally, when you display the user interface from a Spreadsheet, the function does not have to be named doGet. You could instead call it something like displayMyUi, and then call that function directly to display the user interface in your Spreadsheet. When a user interface is displayed from a Spreadsheet, the script runs as the user who's accessing the Spreadsheet.
e.g.
function doGet() {
var app = UiApp.createApplication();
// The very first Google Doodle!
app.add(app.createImage("http://www.google.com/logos/googleburn.jpg"));
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
spreadsheet.show(app);
}
What you are wanting to do is not possible in a Google Spreadsheet, widgets are only available in UiApp or HTML service.
What should be doable is to recreate the spreadsheet display in a Ui and from there use some kind of popup with a mouseOver handler to show the images as you want.
Depending of your use case - mainly on what spreadsheet specific features you want to have when looking at your data - this could be a good or bad solution but only you can answer this last point.
So probably not the cleanest solution, but you can add links to a cell, and when you add a link to an image from your google drive (probably you should make the image avaiable to all with the link) then on mouseover you get a tooltip like box, with preview