Tooltip image on cell hover, Google Spreadsheet - javascript

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

Related

Google Sheet create a hyperlink() like function to open Pop Up message

In Google Sheet, I like to create a general JS/GS function similar to the Hyperlink() function so that I can quickly create a Pop Up message without creating so many JS script.
While we can create all kinds of AppScript function that accept a text variable as the pop up content, the challenge is that we cannot trigger it unless we create some kind of buttons or add a menu option. Both adding button is cumbersome to create and it is not conveniently sized and fixed within a cell. If I have many of such pop up messages across the sheet, it will be pretty difficult to create so many buttons. I have searched all over the net and cannot even find someone asking a similar question not to mention a solution.
The most efficient way is a function which is similar to the hyperlink() function where I can just add the contents of the Pop Up dialog box. I can image the product will be something like the mock up image below.
Please help.
enter image description here
You can use an onEdit() trigger to show the alert. Inside this onEdit() you can set the conditions you want to be applied and set multiple alerts to show.
It is not a ton of code if you want to keep it simple.

I'm currently trying to create a chrome extension (ContextMenu with right click search)

I was trying to include an option which will redirect the user to the google sheets page and select a particular cell as per the selection text in the UI. I already created the contextmenu extension and also associated the google sheets URL in the JavaScript code and it's redirecting as intended.
All that I would like to know is, how can we let the system know that once it reaches the required document, what is the procedure to find a cell in the sheet using URL itself?
Like is there any command we can use after #gid=0, because #fragments would generally mean the end of the parameters and will ignore anything coinciding with it.
I've tried using '/search?q=query' after the doc URL, but no luck
let url = 'https://docs.google.com/spreadsheets/d/fileID/edit#gid=0'

Is there a Google App Scripts sheets event fired when a collaborative user makes an amendment

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.

How to embed excel sheet to web page for editing and uploading it into database

--> 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 am trying to make a real-time auto-correct sort of add-on for Google Docs using Google Apps Script

I am trying to make a real-time auto-correct sort of add-on for Google Docs using Google Apps Script. I have written a lot of code, yet cannot figure out why the fixWords function does not work. Whenever I type a word, it does not auto-correct. This is my code:
function fixWords() {
var body = DocumentApp.getActiveDocument().getBody();
//The start of replacing...
body.replaceText("accomodate","accommodate");
body.replaceText("accomodation","accommodation");
body.replaceText("acheive","achieve");
body.replaceText("accross","across");
body.replaceText("agressive","aggressive");
body.replaceText("agression","aggression");
body.replaceText("apparantly","apparently");
body.replaceText("appearence","appearance");
body.replaceText("arguement","argument");
body.replaceText("assasination","assassination");
body.replaceText("basicly","basically");
}
Any suggestions? I am a newbie to Apps Script but have programming for three years.
There is something in Docs for automatic substitution. Under the tools, menu, click preferences. You can also add a personal dictionary.
If you could add a personal dictionary from code, that would probably work, but I don't see a way to do that.
There is no trigger or way to monitor a Google doc for every keystroke made. See the documentation:
Trigger Events
Something would need to trigger your function to run on every keystroke. In a spreadsheet, there is an onEdit() simple trigger that monitors every change to a cell. But there is nothing like that for Google Docs.
The only event type available to a Google Doc is open.

Categories

Resources