Abdallah Alsamman
Abdallah Alsamman

Reputation: 1672

how can I format a cell in google spreadsheets

I have a spreadsheet that have a column containing github issue numbers, how can I make all the fields in that column a url to the issue on github.
lets say https://github.com/myaccount/myrepo/issues/ is where the issues exist, I want to make all those fields link to "https://github.com/myaccount/myrepo/issues/{existing-issue-nb-here}"

e.g: in line 54, column B(github issue #) should be a hyperlink to https://github.com/myaccount/myrepo/issues/652

enter image description here

Upvotes: 0

Views: 36

Answers (1)

Robin Gertenbach
Robin Gertenbach

Reputation: 10786

If you never overwrite the first row of the column with the links you can use the HYPERLINK formula inside of an array formula

={"github issue #"; 
  ARRAYFORMULA(IF(LEN(B2:B), 
                  HYPERLINK("https://github.com/myacco‌​unt/myrepo/i‌​ssues/" & B2:B,
                  B2:B), ""))}

If you are importing / copy pasting Column B and want to replace it with a link you need to do that with a script that, for every cell does

setFormula("=HYPERLINK(CONCATENATE(https://github.com/myacco‌​unt/myrepo/i‌​ssues/ ,bugId), bugId)")

Where bug ID is either read from the row in column B or in the data you retrieved via script.

Upvotes: 1

Related Questions