来自范围中每个项目的getA1Notation

时间:2012-09-05 22:16:28

标签: google-apps-script

我们如何返回范围内每个项目的A1Notation?

function getA1Notation() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = ss.getSheetByName('Sheet1');
  var range = s.getRange('A1:B3');

  for (var row in range) {
    for (var col in range[row]) 
      Logger.log(range[row][col].getA1Notation());
  }
};

我知道我们不能这样做,但这是我期待的结果......

A1 A2 A3 B1 B2 B3

1 个答案:

答案 0 :(得分:0)

我这样做:

results.formulas = getRangeFormulas(guiRange);
results.a1Notation = new Array(results.formulas.length);
var guiDataSheetName = guiRange.getSheet().getName();
for (var row in results.formulas ) {
  results.a1Notation[row] = new Array(results.formulas[row].length);      
  for (var col in results.formulas[row]) {       
    results.a1Notation[row][col] = guiDataSheetName+"!" + guiRange.offset(row,col,1,1).getA1Notation();
  }
  //Logger.log("5get data"+ (new Date().getTime() - executionTime.getTime()));
}

我在循环外获取工作表名称,因为它需要客户端服务器调用。