我正在寻找 Google Word 文档的内容并将其放入文本框中。以下代码吐出错误:
function listBoxClick(e) {
var tapp = UiApp.getActiveApplication();
var docName = DocsList.find(e.parameter.doclist); //find the document with the same name as what the user clicked on
var docContents = docName[0].getContentAsString(); //get contents of document
tapp.getElementById("songboxID").setValue(songfile2); //set the value of the textBox to the contents of the document
return tapp;
}
这将返回以下错误:
Unsupported conversion requested.
我在某处读到我们无法为 Google 文档执行此操作,但我们可以为我们上传的其他非 Google 文档执行此操作。那正确吗?
这是我不能再发布 5 个小时的答案,因为我是新手并且没有声誉:
在 Serge 的帮助下,这对我有用:
function listBoxClick(e) {
var tapp = UiApp.getActiveApplication();
var docName = DocsList.find(e.parameter.doclist); //get document name based on what user clicked on in listBox
var docId = docName[0].getId(); //get document ID
var content = DocumentApp.openById(docId).getText(); //get contents of document
tapp.getElementById("songboxID").setValue(content); //set web app's textBox (called songboxID) to match the contents of the document the user clicked on
return tapp;
}