Skip to content

Instantly share code, notes, and snippets.

@Cheffheid
Created August 17, 2016 17:50
Show Gist options
  • Save Cheffheid/89e0269379c0fc4d43e473cfe73047c0 to your computer and use it in GitHub Desktop.
Save Cheffheid/89e0269379c0fc4d43e473cfe73047c0 to your computer and use it in GitHub Desktop.
Basic Google Sheets script for generating HTML based on row data
/*
* Generates a snippet of HTML code based on data in cells.
* Usage: On a sheet, select "Tools" -> "Script editor" and paste below (modify output as necessary)
* Then set the value for a blank column to =generateHTML(dateCell, titleCell, locationCell, linkCell)
* ie. =generateHTML(B2, C2, D2, E2)
*/
function generateHTML(date, title, location, link) {
var html = Utilities.formatString(
'<tr>\n<td>%s</td>\n<td><strong>%s</strong></td>\n<td>%s</td>\n<td><a href="%s" target="_blank">Sign Up Here</a></td>\n</tr>',
Utilities.formatDate(date, "GMT", "MM/dd/YY"),
title,
location,
link
);
return html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment