我正在导出Google日历事件,描述中是超链接文本。当我导出到表格时,我得到
测试事件:<a href="https://xxxx/following"> Registration</a>
我需要导出为真正的超链接文本,或者将Google表格中的单元格文本转换回超链接文本。
这是[示例导出](https://docs.google.com/spreadsheets/d/1ojtLP1HOXrH4q3Rr7T4KRR86rtC_XM1F2KhgQClhDUA/edit#gid=0)
澄清 我愿意将列分为2列,以使以下结果显示为超链接。 测试事件: Registration
答案 0 :(得分:0)
这是一个示例函数,它将按照您描述的格式将链接分为单独的text和URL列:
/**
* Splits an html <a> tag into its text content and URL components
* @param {string} Format is: "Optional leading text: <a href="url">Link Text</a>"
* @returns {string[][]} 1 row by 2 column string of text and url
* @customfunction
*/
function LINKSPLIT(string) {
var split = /(^[^<]*)(<a.*a>)/.exec(string);
try {
var document = XmlService.parse(split[2]);
} catch (error) {
throw new Error("Format is: \"Optional leading text: <a href=\"url\">Link Text</a>\"");
}
var content = document.getAllContent();
if (content.length != 1) {
throw new Error("XML parser found multiple tags. Please enter a single <a> tag only.");
}
return [[split[1] + content[0].getText(), content[0].getAttribute("href").getValue()]];
}
它写为custom function for Google Sheets,即您可以使用=LINKTEST(ROW:COLUMN)
在单元格中测试的东西。如果要通过脚本导入日历事件,则可以使用此示例并将其合并到脚本中,以便它在导入过程中解析链接。