Created
February 16, 2012 13:26
-
-
Save holysugar/1844818 to your computer and use it in GitHub Desktop.
Google SpreadSheets Auto Link Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ticketLink() { | |
// configuration | |
var sheetName = 'Sample1'; | |
var redmineUrl = 'http://redmine.example.com/issues/'; | |
var targetRange = 'A2:A'; | |
var doc = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = doc.getSheetByName(sheetName); | |
var all = sheet.getRange(targetRange); | |
var height = all.getHeight(); | |
for (var i = 1; i <= height; i++) { | |
var cell = all.getCell(i, 1); | |
var v = cell.getValue(); | |
if (v.toString().match(/^#(\d+)/)) { | |
var ticket = RegExp.$1; | |
var formula = '=HYPERLINK("' + redmineUrl + ticket + '";"' + v + '")'; | |
cell.setFormula(formula); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script Editor で突っ込んで trigger を適当に設定すれば自動的に実行される