Answer the question
In order to leave comments, you need to log in
How to change default link/hyperlink formatting in Google Sheets?
When I place new links or hyperlinks in the table, they are automatically formatted (turn blue and underlined). How can I remove or change this default formatting? I want links to look like plain text
Answer the question
In order to leave comments, you need to log in
Here is the code that will display the links as text (but they, however, will remain links)
/**
* Возникает при изменении ячейки
* Боев Григорий (с) 2020 (telegram @ProgrammerForever)
* @param {event} event event-объект https://developers.google.com/apps-script/guides/triggers/events?hl=ru
* @return Не возвращает значений
* @customfunction
*/
function onEdit(event) {
var newValue = event.value; //Новое значение
var r = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
var style = SpreadsheetApp.newTextStyle()
.setBold(false)
.setUnderline(false)
.setForegroundColor("#000000")
.build();
var richText = SpreadsheetApp.newRichTextValue()
.setText(newValue)
.setTextStyle(style)
.build();
if (r.test(newValue)){
SpreadsheetApp.getActiveRange().setRichTextValue(richText);
};
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question