javascript - Google App 脚本删除 GDoc 中的表列
问题描述
我正在编写一个脚本来自动创建报告,该脚本创建一个谷歌文档并用来自不同来源的信息填充它,该报告有一个使用以下代码从谷歌电子表格复制的表格:
// get the Spreadsheet by sheet id
var source = SpreadsheetApp.openById(OPERATIONS_FILE);
// select the sheet
var sourcesheet = source.getSheetByName(OPERATION_SHEET);
// get the values on selectd range
var srcData = sourcesheet.getRange(OPERATION_RANGE).getValues();
// Set the variable templates on the new Report
var newReport = DocumentApp.openById( reportFile.getId() );
var reportBody = newReport.getBody();
reportBody.replaceText('{date}', dateForTitle);
reportBody.replaceText('{workWeek}', weekNumber[1]);
// Get the data from the Dashboard and put it on the Report
var range = reportBody.findText("{operation}");
var operationsTable = "";
var ele = range.getElement();
if (ele.getParent().getParent().getType() === DocumentApp.ElementType.BODY_SECTION) {
var offset = reportBody.getChildIndex(ele.getParent());
operationsTable = reportBody.insertTable(offset + 1, srcData);
}
现在插入到谷歌文档“操作表”中的表格包含我需要删除的额外列(电子表格中需要这些列用于计算目的)我在谷歌脚本文档中找到了 RemoveRow(I) 函数,但找不到 RemoveColumn(I)一旦在谷歌文档上,你如何删除表格的某些列?
解决方案
推荐阅读
- javascript - 隐藏数据时完全隐藏chartjs上的Y轴
- excel - 如何复制范围内的两个不相邻的列
- angular - Angular / RxJS - 链接两个 http get 调用
- c++ - 如何在 QML 应用程序中显示本机窗口?
- git - 将 git 存储库部署到实时服务器会覆盖现有文件吗?
- html - mat-expansion-panel-header 根据是否展开动态改变背景颜色
- php - 致命错误:php
- javascript - 将 Bot 变量放入不同的 Commando 文件
- facebook - 无需应用即可管理 Facebook 页面和群组
- tfsbuild - TFS 2017 构建实际上并未进行构建