小编Stu*_*y17的帖子

使用 Google Apps 脚本将文本占位符替换为图像

在此输入图像描述

我试图将四个图像放入我的谷歌文档中,它们应该被格式化为相同的大小并在一个正方形内。我正在尝试替换文本占位符,但我愿意接受其他方法。

图像 URL 位于我的 google 工作表中,我将它们初始化为变量。

我试图循环遍历 4 个图像中的每一个,并用它们替换每个相应的文本占位符。

function createDocument() {
  var headers = Sheets.Spreadsheets.Values.get('1Yy70i8aQ3GZEp5FE5mhO458Bmivu01ZeykG0GFZmrVo', 'A4:AL4');
  var tactics = Sheets.Spreadsheets.Values.get('1Yy70i8aQ3GZEp5FE5mhO458Bmivu01ZeykG0GFZmrVo', 'A5:J26');
  var templateId = '1ajVQxJAgGxXF3ivkaWL5WEv2xhiJc9r0YwxLH5Hm17w';
      
  for(var i = 0; i < tactics.values.length; i++){
        
        // see what the sheets API is returning
        Logger.log(tactics);
        
        // initialise variables from the sheet
        var projectID = tactics.values[i][0];
        var projectName = tactics.values[i][1];
      
        // copy our template and capture the ID of the copied document
        var documentId = DriveApp.getFileById(templateId).makeCopy().getId();
        
        // name the copied doc by projectID …
Run Code Online (Sandbox Code Playgroud)

google-docs google-sheets google-apps-script

3
推荐指数
1
解决办法
2884
查看次数