我对谷歌脚本相当陌生。我一直在从 VBA 翻译一个人的代码来为我的属性编写我自己的数据库。目标是将属性数据存储在属性数据库表上,并拥有另一个“摘要表”,允许我查看选定属性的数据,对其进行编辑并将其更新到数据库中。
我通过将汇总表中的单元格 a1Notation 放在数据库表中相应单元格的上方来使用数据映射。我使用for Loop将数据库表中所选属性数据加载到摘要表中,该摘要表在选择属性时使用ONEDIT执行。问题是它太慢了。见下文。我能做些什么来加快速度吗?谢谢!
定义:
var PropRow, PropCol, PropID
var app = SpreadsheetApp;
var activeSheet = app.getActiveSpreadsheet(); //Get current active spreadsheet
var sheetProp = activeSheet.getSheetByName('Properties');
var sheetPropDB = activeSheet.getSheetByName('PropDB');
将属性数据从属性数据库 (sheetPropDB) 加载到汇总表 (sheetProp)。这是非常慢的部分:
function Property_Load(){
sheetProp.activate();
PropRow = sheetProp.getRange('B7').getValue();
for(PropCol = 3; PropCol<43; PropCol++){
var dataLOC = sheetPropDB.getRange(2,PropCol).getValue(); // gets data mapping cell addresses from PropDB tab
var dataVAL = sheetPropDB.getRange(PropRow,PropCol).getValue(); //gets values of cells in PropDB sheet located at the selected properties PropRow and for each PropCol
var dataPASTE = sheetProp.getRange(dataLOC); // highlights the cells on the Property tab given by the addresses in dataLOC
dataPASTE.setValue(dataVAL); // pastes the values from the propDB selected property row into the specified cells of the property tab
}
}