簡體   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