繁体   English   中英

是否可以将 XML 或 JSON 数据从 Word 在线文档中的表格作为 HTML 表格导入 Apps Script 网站?

[英]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 脚本构建一个网络应用程序。 在此 Web 应用程序中,我有一个表,需要从 OneDrive 中 Word 文档中的表填充。 本文档会定期更新,因此我更愿意以编程方式更新 Apps Script 中 html 表的内容。 这可能吗? 如果是这样,任何人都可以指导我如何实现这一目标吗?

我已经开始研究从 url 导入 xml,但我不确定我是否走在正确的轨道上。

您需要合并以下步骤

  • 将您的数据读入 Google Apps 功能,例如使用 Cooper 推荐的OneDriveApp
  • 使用google.script.run从你的html文件中调用 Apps Script 函数
  • 结合网络轮询功能,以所需的时间间隔用新鲜内容更新您的 html 表格

样本:

代码.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;
}

索引.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>
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM