我不知道如何将文本写入文档中的表格单元格中。我可以读取单元格,getRow(0).getCell(0),但不能更改单元格内的文本。
正如在下面的注释中所指出的,我的可变文本确实显示旧的单元格字符串已被清除并插入了新的字符串;但是,我的文档中的实际单元格保持不变,包含原始的旧字符串。
var doc = DocumentApp.getActiveDocument().getBody();
var tables = doc.getTables();
var cell = tables[0].getRow(0).getCell(0);
var text = cell.getText(); // the string is the expected from document.
cell.clear();
cell.setText('text');
var text = cell.getText(); // text = 'text' but the cell on document remains unchanged.发布于 2014-07-09 20:55:43
使用.editAsText()获取单元格内的 object。
var text = cell.editAsText();可以使用以下方法检索来自Text对象的强值:
var string = text.getText();并以:
text.setText('blahblah');https://stackoverflow.com/questions/24663247
复制相似问题