Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add "custom function help" to a google spreadsheet. - not the script editor

It is possible to add "custom function help" to a google spreadsheet? i.e. If I type =sum into a spreadsheet cell, I get floating help text, is there a way to do this with custom functions?

Documentation in google apps script is created using JSDoc http://en.wikipedia.org/wiki/JSDoc style (JavaDoc like) comments. as documented here https://developers.google.com/apps-script/guide_libraries?hl=en#guidelines

it looks like these only work in the script editor. It there a way of adding documentation so it appears on the spreadsheet.

like image 573
eddyparkinson Avatar asked Feb 22 '13 01:02

eddyparkinson


People also ask

What language can you use to write a custom function for Google Sheets?

Custom functions for Google Sheets are written with JavaScript code. If you're an expert in JavaScript you'll feel right at home. If not, it's a simple language that you can learn with a JavaScript cheat sheet.

Why does my Google Sheets not have script editor?

If the Tools --> Script Editor and the Add-ons menu options are missing when you open the file, it probably isn't actually a Google Sheets file. Make sure to navigate to File --> Save As Google Sheets. Then the Script Editor option in the Tools menu and the Add-ons menu will be available. Save this answer.


1 Answers

This capability was added in May 2014, and the previous Issue 2475 has been closed.

The examples given in Google's Documentation are OK, but you can do more with the jsdoc information than they show.

For example:

/**
 * Return the time that the referenced cell or range was last changed.
 * Initial use shows current time.
 *
 * @param {Sheet3!B32}  reference  Cell or range to monitor.
 * @returns                        The time the reference was last changed.
 * @customfunction
 */
function lastModified( reference ) {
  // Surprise - we don't actually care what has changed!
  return( new Date() );
}

screenshot

I covered this with more detail and examples in my blog.

like image 113
Mogsdad Avatar answered Sep 28 '22 09:09

Mogsdad