URL Escape Strings in Google Spreadsheets with a Simple Script

I tweeted recently that I was very, very excited about scripting for Google Spreadsheets. Combine the ability to write custom javascript functions to manipulate data in spreadsheets with the already killer collaboration features of Google Spreadsheets and the ability to import data from web streams, and now you have something far, far more powerful than Excel (we just need some keyboard shortcuts!).

This morning, I wrote my first script, a URL escape function that is going to help me generate query strings based on spreadsheet values. To write a script, click Tools > Scripts > Edit

Edit Scripts in Google Spreadsheets

Edit Scripts in Google Spreadsheets

Here is the simple script I wrote:

function venmo_esc(str) {
return encodeURIComponent(str);
};

I saved this, and now in any cell I can output an escaped version of the contents of another cell like this:

=venmo_esc(D2)

This simple example alone has already proved quite useful. I am looking forward to doing a lot more advanced stuff to beef up our already extensive use of Google Spreadsheets to build tiny collaboration apps for our business and day to day work.

Related posts:

  1. Locking a Reference to a Fixed Row or Column in Google Spreadsheets
  2. Quick Add Event to Google Calendar with Google Chrome Address Bar Shortcut
  3. Bash Script to Cron for Deleting Old Log Files
  4. Get Directory of Bash Script Being Executed
  5. Search Browser History Quickly with a Google Chrome Address Bar Shortcut
You should follow me on Twitter here.
Subscribe to labs via email here.

About this entry