【发布时间】:2018-04-28 20:36:39
【问题描述】:
上下文:我将 G 表单数据插入到 G 表中,然后将新行附加到我在 G Doc 上的表上。 Google Doc Table 中的最后一列我想提供一个带有“编辑”一词的超链接。
我想实现 .link 的功能,但它插入了在文档中不起作用的 html。 https://www.w3schools.com/jsref/jsref_link.asp
这是我直接在 G 表中的脚本(提交表单时):
// Grab the Table
var body = DocumentApp.openById('theId').getBody(),
searchElement = body.findElement(DocumentApp.ElementType.TABLE),
element = searchElement.getElement(),
table = element.asTable();
// Wait for row insertion to finish, so that sheet.getLastRow() method gets the updated number of rows
Utilities.sleep(1000); // 1 second
// Get the last row ID
var mySs = SpreadsheetApp.openById('sheetId').getSheets()[0];
var lastRowId = mySs.getLastRow();
var hyperlink = mySs.getRange('L' + lastRowId).getValue();
// Insert the Row
var cells = [lastRowId, hyperlink];
var addRow = table.appendTableRow();
cells.forEach(function(e, i){
addRow.insertTableCell(i, e);
});
body.saveAndClose();
所以现在它直接将超链接添加到 google 表单。而我想将单元格数组中的当前超链接变量切换为实际的超链接,上面写着“编辑”,它具有超链接变量 URL。
我尝试直接从 G 表单中添加脚本数据示例
var hyperlink = '=HYPERLINK("www.google.com", "Google")';
它工作并将超链接插入到 G 表。问题是它无法将其带到 G Doc。我想可能是因为 G Sheet 公式无法提取到 G Doc Tables 中?
【问题讨论】:
标签: javascript google-apps-script