如何插入参数

How to insert a parameter in

我需要在其中插入一个参数:

row: workbook.getWorksheet("VittorioZigiotto").getRange("VittorioZigiotto[237]:Vittorioigiotto[241]")

参数需要位于现在“237”所在的位置,并且需要依赖于工作簿中的单元格。例如,货币页 1!A1+5。有什么想法吗?

您可以从 MONEYPAGE!A1 中获取您想要的值而不是 237,方法如下:

const valueFromMPA1 = workbook.getWorksheet("MONEYPAGE").getRange("A1").getValue(); // use getValue for convenience since it's a single cell
const rowString = `VittorioZigiotto[${valueFromMPA1}]:VittorioZigiotto[${valueFromMPA1 + 5}]`; // this is a js/ts way to construct strings with params
// and then pass that in as the argument ...
const row = workbook.getWorksheet("VittorioZigiotto").getRange(rowString);

我不确定你的具体情况,但也可以看看 .getRangeByIndexes(而不是 getRange),它可以让你传递数字 row/column 值,而不必构造字符串参数。