本文介绍了是否可以将Word联机文档中的表中的XML或JSON数据作为HTML表导入到Apps Script网站中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Apps Script构建一个Web应用程序.在此Web应用程序中,我有一个需要从OneDrive中的Word文档中的表填充的表.该文档会定期更新,因此,我希望以编程方式更新Apps脚本中html表的内容.这可能吗?如果是这样,有人可以给我指导如何完成此工作吗?
I am building a web app using Apps Script.In this web app I have a table that needs to be populated from a table in a Word doc in OneDrive.This document is updated regularly, so I would prefer to programmatically update the content of the html table in Apps Script.Is this possible?If so, can anyone give me guidance as to how to accomplish this?
我已经开始考虑从URL导入xml,但是我不确定自己走的路是否正确.
I've started looking into importing xml from a url, but I'm not sure that I'm on the right track.
推荐答案
您需要合并以下步骤
- 将数据读取到Google Apps功能中,例如根据库珀的建议使用
OneDriveApp
- 使用 google.script.run 从您的
html
文件中调用Apps脚本功能 - 并入网络轮询函数,该函数使用所需的新鲜内容更新html表间隔
- Read your data into a Google Apps function, e.g. with
OneDriveApp
as recommended by Cooper - Use google.script.run to call the Apps Script function from you
html
file - Incorporate a Web Polling function that updates your html table with fresh contents in desired intervals
You need to incorporate the following steps
示例:
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;
}
...
<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>
...
这篇关于是否可以将Word联机文档中的表中的XML或JSON数据作为HTML表导入到Apps Script网站中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!