0

我正在尝试使用 Office Scripts for Excel Online 将修改行的日期插入到该特定行的修改日期列中。这是我能得到的最接近的,因为我还没有找到只获得需要动态的修改行的脚本。详细信息在下面代码的注释中:

function main(workbook: ExcelScript.Workbook) {
// This finds the location of the cell at K2 (Modified Date column is on K:K) but actually 
//want to get the modified row location.
 let datetimeRange = workbook.getWorksheet("Form1").getRange("K2");

// Get dynamic range of the worksheet. I'm not sure if this will work since there might be 
//some blanks. The number of rows and possibly columns will change so needs to be dynamic.
let myRange = 
workbook.getWorksheet("Form1").getRange("A1").getSurroundingRegion().getAddress();

// Get the current date and time with the JavaScript Date object.
let date = new Date(Date.now());

// This adds the date string to K2 but actually only want it added to Modified Date in the 
//Modified Date column (dynamic since columns can change) for only the row that was modified.
datetimeRange.setValue(date.toLocaleDateString() + ' ' + date.toLocaleTimeString());
 }

在此处输入图像描述

4

0 回答 0