簡體   English   中英

html 文件和腳本沒有產生正確的輸出(谷歌表格)

[英]html file and the script not resulting correct output (Google Sheets)

我一直試圖讓這個工作,但沒有成功......

我在電子郵件中得到的輸出是純文本,就像文件中寫入的 html 一樣。 還有更多內容,但我確定 flw 位於共享腳本的一部分內。

這是腳本和 html 文件:

function emailUpdatedStatus() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Atividades");
  var history = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Updates');
  var historyData = history.getRange(5,1,history.getLastRow(),5).getValues();
  var startRow = 9;  // First row of data to process
  var numRows = sheet.getLastRow();   // Number of rows to process
  var dataRange = sheet.getRange(startRow, 1, numRows, 24);
  
  //Variables for the Email Formatted Table
  const reportTitle = "Histórico da Atividade";
  const subHeader = history.getRange("B3").getValue();
  const headers = history.getRange("A4:E4").getValues();
  const lastTbUpdate = headers[0][0];
  const histTbNo = headers[0][1];
  const histTbStatus = headers[0][2];
  const histTbObs = headers[0][3];
  const histTbUser = headers[0][4];
  const histLastRow = history.getLastRow();
  const tableRngValues = history.getRange(5, 1, histLastRow-5,5).getValues();
  
  const htmlTemplate = HtmlService.createTemplateFromFile('email');
  htmlTemplate.reportTitle = reportTitle;
  htmlTemplate.subHeader = subHeader;
  htmlTemplate.lastTbUpdate = lastTbUpdate;
  htmlTemplate.histTbStatus = histTbStatus;
  htmlTemplate.histTbNo = histTbNo;
  htmlTemplate.histTbObs = histTbObs;
  htmlTemplate.histTbUser = histTbUser;
  htmlTemplate.tableRngValues = tableRngValues;
  
  const htmlForEmail = htmlTemplate.getContent();
  }
<!DOCTYPE html>
<html>
    <head>
        <base target=_top>
        </head>
        <body>
            <div>
                <div></div>
                <div>
                    <h1>
                        <?= reportTitle ?>
                    </h1>
                    <div>
                        <? subHeader ?>
                    </div>
                    <div></div>
                    <table>
                        <thead>
                            <tr>
                                <td>
                                    <?= lastTbUpdate ?>
                                </td>
                                <td>
                                    <?= histTbStatus ?>
                                </td>
                                <td>
                                    <?= histTbObs ?>
                                </td>
                                <td>
                                    <?= histTbUser ?>
                                </td>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>
                                    <?=  ?>
                                </td>
                                <td>
                                    <?=  ?>
                                </td>
                                <td>
                                    <?=  ?>
                                </td>
                                <td>
                                    <?=  ?>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </body>
    </html>

任何關於缺陷所在的線索都值得贊賞。

代替

const htmlForEmail = htmlTemplate.getContent();

經過

const htmlOutput = htmlTemplate.evaluate();
const htmlForEmail = htmlOutput.getContent();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM