是否可以将 Word 在线文档中 table 中的 XML 或 JSON 数据作为 HTML table 导入 Apps 脚本网站?
Is it possible to import XML or JSON data from a table within a Word online document into Apps Script website as an HTML table?
我正在使用 Apps 脚本构建网络应用程序。
在此网络应用程序中,我有一个 table 需要从 OneDrive 的 Word 文档中的 table 填充。
该文档会定期更新,因此我更愿意以编程方式更新 Apps 脚本中 html table 的内容。
这可能吗?
如果是这样,谁能指导我如何完成此操作?
我已经开始研究从 url 导入 xml,但我不确定我是否走在正确的轨道上。
您需要合并以下步骤
- 将您的数据读入 Google 应用功能,例如根据 Cooper
的推荐 OneDriveApp
- 使用 google.script.run 从您的
html
文件中调用 Apps 脚本函数
- 合并 Web Polling 功能,以所需的时间间隔更新 html table 的新内容
样本:
code.gs
function doGet(){
return HtmlService.createHtmlOutputFromFile('index');
}
function getFreshData(){
//read here your Word Doc data, e.g. with One DriveApp and store it e.g. in an array
...
return myDataArray;
}
index.html
...
<body onload="polling()">
...
<script>
function polling(){
setInterval(myFunction,2000); //chose how often you want your table
}
function myFunction(){
google.script.run.withSuccessHandler(onSuccess).getFreshData();
}
function onSuccess(myDataArray){
// Create a html table with the freshly obtained myDataArray from the Word Doc
...
}
</script>
...
我正在使用 Apps 脚本构建网络应用程序。 在此网络应用程序中,我有一个 table 需要从 OneDrive 的 Word 文档中的 table 填充。 该文档会定期更新,因此我更愿意以编程方式更新 Apps 脚本中 html table 的内容。 这可能吗? 如果是这样,谁能指导我如何完成此操作?
我已经开始研究从 url 导入 xml,但我不确定我是否走在正确的轨道上。
您需要合并以下步骤
- 将您的数据读入 Google 应用功能,例如根据 Cooper 的推荐
- 使用 google.script.run 从您的
html
文件中调用 Apps 脚本函数 - 合并 Web Polling 功能,以所需的时间间隔更新 html table 的新内容
OneDriveApp
样本:
code.gs
function doGet(){
return HtmlService.createHtmlOutputFromFile('index');
}
function getFreshData(){
//read here your Word Doc data, e.g. with One DriveApp and store it e.g. in an array
...
return myDataArray;
}
index.html
...
<body onload="polling()">
...
<script>
function polling(){
setInterval(myFunction,2000); //chose how often you want your table
}
function myFunction(){
google.script.run.withSuccessHandler(onSuccess).getFreshData();
}
function onSuccess(myDataArray){
// Create a html table with the freshly obtained myDataArray from the Word Doc
...
}
</script>
...