【发布时间】:2021-07-16 02:08:24
【问题描述】:
我需要从一个 Excel 工作表中复制数据,然后使用 Power Automated + Office 脚本将数据(仅限值)粘贴到另一个工作表上
我开始使用下面链接中的答案创建流程。
Power Automate: Copy Excel OneDrive table to the bottom of another Excel OneDrive table
问题是我没有理解第二个脚本,所以我无法将它修改为我需要的(工作簿末尾的那个粘贴)
链接上的脚本
For Run script I have
function main(workbook: ExcelScript.Workbook) {
const sheet = workbook.getWorksheets()[0];
let lastRow = sheet.getUsedRange(true).getLastCell().getRowIndex() + 1;
let rng = "A3:P" + lastRow
let tableTest = sheet.getRange(rng).getValues();
console.log(tableTest);
}
Then under Compose
@{outputs('Run_script')?['body']?['Logs'][0]}
Then Initialize the "RemoveString" variable
@{split(outputs('Compose'),' ')[0]}
Then Initialize the "NewString" variable
@{replace(outputs('Compose'),variables('RemoveString'),'')}
Then Run Script 2 and add "NewString" as the parameter.
function main(workbook: ExcelScript.Workbook, rangeTest: string) {
let table = workbook.getTable("BacklogTable");
let str = rangeTest;
let testerTest = JSON.parse(str);
table.addRows(null, testerTest);
}
RemoveString 的原因是从输出中删除日期和时间戳
【问题讨论】:
-
嘿,我回答了这个问题,你想做什么不同的事情?你收到错误或什么?还是要将其添加到不是表格的单元格中?
-
我对办公脚本知之甚少,但如果它是一个表格,这不是问题,但我需要将信息粘贴到特定单元格并替换信息
-
好的,您希望它粘贴到哪个单元格中?
-
从 A7 开始,之前复制的表格范围(粘贴为数字)
-
这回答了你的问题吗?
标签: onedrive power-automate excel-online office-scripts