google-apps-script 相关问题

用于解答有关Google Apps脚本的问题,这是Google基于JavaScript的云脚本语言,用于自动执行Google产品和第三方服务中的任务。

Google 脚本将附件保存到 GDrive,无需重复

使用 Google Workspaces,我需要一个脚本将附件从日常电子邮件(始终具有相同的发件人、主题和附件名称)移至 Google 云端硬盘中的文件夹。 我已经尝试过几种

回答 2 投票 0

根据可见列更改 Google 表格中图表的大小

我有一张谷歌表格,用于每年的预算。我通常为每年创建一个新选项卡,但分组列功能意味着我可以隐藏完整的年份,这是理想的。 我...

回答 1 投票 0

如何根据进行更改的选项卡运行 Google Apps 脚本?

我正在跟进昨天的这个问题:How to Run onEdit/onChange function in Google Apps Script on Data Pull Dynamically using Query 接受的答案对我有用。但现在我...

回答 1 投票 0

是否可以使用 Google Apps 脚本创建与 QuickBooks 桌面的 API 连接?

我看过一些文章,演示如何使用 Apps 脚本连接到 QuickBooks Online 的 API。我只是想知道是否可以对 QuickBooks Desktop 做同样的事情。我的考试用例...

回答 1 投票 0

如何从之前的部署恢复代码

简短的问题:如何恢复/检索以前部署的代码(html,gs)? 更长:我多年前就有一些编码经验,但实际上我还是个新手。我有...

回答 1 投票 0

获取(新创建的)Textarea 的值并将其插入 Google Sheets

我有很多文本区域,并且可以创建新的文本区域。我使用 insertValue 按钮将文本区域的值插入到电子表格中。我的代码如下: HTML: 我有许多文本区域,并且可以创建新的文本区域。我使用 insertValue 按钮将文本区域的值插入到电子表格中。我的代码如下: HTML: <!DOCTYPE html> <html> <body> <div class="container"> <input type="text" id="qnumberDS" placeholder="Enter question"> <textarea id="contentDS" placeholder="Enter question content"></textarea> <div class="options"> <div class="option"> <input type="checkbox" id="ch1" class="checkbox"> <textarea id="a" class="option-textarea" placeholder="Enter option A"></textarea> </div> <div class="option"> <input type="checkbox" id="ch2" class="checkbox"> <textarea id="b" class="option-textarea" placeholder="Enter option "></textarea> </div> <div class="option"> <input type="checkbox" id="ch3" class="checkbox"> <textarea id="c" class="option-textarea" placeholder="Enter option C"></textarea> </div> <div class="option"> <input type="checkbox" id="ch4" class="checkbox"> <textarea id="d" class="option-textarea" placeholder="Enter option D"></textarea> </div> </div> <button id="insertRow">Add options</button> <button id="insertValue">Send data</button> </div> <script> const qnumberDSInput = document.getElementById('qnumberDS'); const contentDSInput = document.getElementById('contentDS'); const optionsContainer = document.querySelector('.options'); const insertRowButton = document.getElementById('insertRow'); const insertValueButton = document.getElementById('insertValue'); function insertRow() { const newOption = document.createElement('div'); newOption.classList.add('option'); const newCheckbox = document.createElement('input'); newCheckbox.type = 'checkbox'; newCheckbox.id = `ch${optionsContainer.children.length + 1}`; newCheckbox.classList.add('checkbox'); newOption.appendChild(newCheckbox); const newTextarea = document.createElement('textarea'); newTextarea.id = String.fromCharCode(97 + optionsContainer.children.length); newTextarea.classList.add('option-textarea'); newTextarea.placeholder = `Nhập phương án ${String.fromCharCode(97 + optionsContainer.children.length)}`; newOption.appendChild(newTextarea); optionsContainer.appendChild(newOption); } function insertValue() { const title = qnumberDSInput.value; const content = contentDSInput.value; const data = []; optionsContainer.querySelectorAll('.option').forEach((option, index) => { const checkbox = option.querySelector('.checkbox'); const textarea = option.querySelector('.option-textarea'); const optionValue = textarea.value; const isChecked = checkbox.checked; const optionData = { value: optionValue, isCorrect: isChecked ? 'Đ' : 'S' }; if (!data[data.length - 1].options) { data[data.length - 1].options = []; } data[data.length - 1].options.push(optionData); }); google.script.run.enterNameDS(data); } insertRowButton.addEventListener('click', insertRow); insertValueButton.addEventListener('click', insertValue); </script> </body> </html> js: function enterNameDS(data) { var ss = SpreadsheetApp.getActiveSpreadsheet(); var shTitle = ss.getSheetByName('title'); var sh = ss.getSheetByName('tests'); var numPart1 = Number(shTitle.getRange('E8').getValue()); data.forEach(question => { const formulas = [question.title, `="${question.content}"`]; question.options.forEach(option => { formulas.push(`=if(column()=${option.position + 3};"${option.value}";"")`); }); sh.getRange(numPart1 + 1, 1, 1, formulas.length).setFormulas([formulas]); numPart1++; }); shTitle.getRange('E8').setValue(numPart1); } 不知道错误是在HTML中还是在js中。我不知道如何查找 HTML 中嵌入的脚本代码中的错误。 我真的需要你的帮助来查找这段代码中的错误。谢谢你。 问题在于 insertValue() 中,您需要将选项推入数据数组,而不是推入 data[].options。 即: data.push(optionData); 如果您不知道如何调试 html 文件中的 javascript,那么我建议您将其移至它自己的 .js 文件中,您知道如何调试它。只需记住在 html 区域中包含一个脚本命令即可执行。 <script defer src="/javascript_libraries/myJavascript.js"></script> 这是工作的 insertValue() 函数: function insertValue() { const title = qnumberDSInput.value; const content = contentDSInput.value; const data = []; optionsContainer.querySelectorAll('.option').forEach((option, index) => { const checkbox = option.querySelector('.checkbox'); const textarea = option.querySelector('.option-textarea'); const optionValue = textarea.value; const isChecked = checkbox.checked; const optionData = { value: optionValue, isCorrect: isChecked ? 'Đ' : 'S' }; // NOTE: This is push replaces the other two data.push(optionData); }); google.script.run.enterNameDS(data); }

回答 1 投票 0

当按下 Google Sheet 上的按钮时,如何将选定的数据从 Sheet 1 复制到 Sheet 2?

从 Sheet 1 中选择数据行,然后按提交复制到 Sheet2 Sheet2 上的表已包含数据。 通过复选框选择 Sheet1 上表中的数据。 按提交按钮。 添加从

回答 1 投票 0

在 Apps 脚本中按时间升序排序

我有一个 Google 表格文档,其中从第 3 行开始包含以下信息:A 列中的名称、B 列中的时间和 C 列中的组。我正在尝试对所有这些信息进行排序...

回答 1 投票 0

发出 HTTP POST 请求时“JavaScript 运行时意外退出”

我正在开发一个与 Canvas Data 2 API 和 Google Cloud Storage 交互的 Google Apps 脚本。该脚本从 API 检索数据,对其进行处理,然后将其上传到 Google Cloud Storage,

回答 1 投票 0

G日历:搜索所有系列日期

如何使用 GScript 搜索我的所有系列约会并控制输出,以便仅显示已设置系列约会的约会? 我已经创建了一个

回答 1 投票 0

Google Apps 脚本测试模式参数

如何在测试模式下将参数传递给 Google Apps 脚本? 当我构建 Apps 脚本并发布为内容服务时,我可以在生产环境的查询字符串中传递参数...

回答 1 投票 0

doGet(request) 中的统一测试

我正在开发一个简单的谷歌脚本并将其发布为网络应用程序。 我的方法的开始如下: 函数 doGet(请求) { var start = request.parameters.start; var end = 请求。

回答 1 投票 0

QUnit 删除依赖项上的方法会破坏针对该依赖项的测试

在 Google Apps 脚本中,我正在使用 QUnit、测试驱动开发对我正在开发的应用程序进行单元测试。 正在测试的代码 我现在正在致力于全面测试,然后进行开发......

回答 1 投票 0

需要帮助从谷歌表格的下拉列表中记录

我在谷歌表格上有一个下拉菜单,每次从列表中选择某些内容或更改为“记录”列时都希望进行记录。 例子, 下拉(单元格 A2)选项是...

回答 1 投票 0

“For”循环仅在 Google 电子表格的 Apps 脚本中有效一次

所以我在 IT 课上,我们正在为 Google 表格制作自定义菜单,我很好奇,我想制作某种菜单循环。具有这种结构的东西:菜单 -> 子菜单 1 -> Subm...

回答 1 投票 0

onChange(e) 拒绝触发

我使用 ChatGPT 的帮助来尝试获取一个函数,当目标单元格(单元格 B)从 5 更改其值时,该函数会更改设置单元格(单元格 C)的值。这就是我最终得到的函数。 功能

回答 1 投票 0

Google Apps 脚本超出执行时间,因为有太多单元格需要从一张工作表复制到另一张工作表

我有一项例行任务,将数据从一张工作表复制到另一张工作表。我的源工作表通常具有不同数量的单元格,但始终约为 300k 行和 6 列。所有复制的数据都是必要的...

回答 1 投票 0

当某个单元格中的值第一次=X时发送电子邮件

我目前正在使用 Google Sheets 中的 importhtml 函数从几个不同的网站抓取值,然后将抓取的数据与我自己网站的数据进行比较。我网站上的价值观是...

回答 1 投票 0

应用程序脚本 G Sheets 在特定单元格编辑上自动发送电子邮件

我有四个选项卡,其中包含相似的信息集。 当选项卡 1 中的下拉菜单设置为“新”时,我希望它向特定人员发送电子邮件。 我遇到的问题是当选项卡 2 为

回答 1 投票 0

使用 Google Apps 脚本将 Shopify 客户数据导入 Google 表格

我正在尝试从 Shopify 获取客户数据,但在 API 响应中找不到一个参数。以下是截图: 我想要获得用绿色括起来的 6 月 6,7,8 日的值。这是代码

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.