5

Javaを介してGoogleのスプレッドシートサービスから列の最初の空のセルを取得する良い方法はありますか?

私は使用できることを知っています:

public CellFeed CheckColumn(int row, int col) 
    throws IOException, ServiceException {
    CellQuery query = new CellQuery(cellFeedUrl);
    query.setMinimumRow(row);
    query.setMaximumRow(row);
    query.setMinimumCol(col);
    query.setMaximumCol(col);
    query.setReturnEmpty(true);

    CellFeed feed = service.query(query, CellFeed.class);
    int cell_loc[];

    for (CellEntry entry : feed.getEntries()) {
       cell_loc=CheckIfEmpty(entry);   
    }
    return cell_loc;
}

エントリをウォークスルーしますが、列全体を一度にロードするのではなく、ユーザーにとっては遅く、列全体をウォークスルーするのは悪いようです。

何かご意見は?

4

1 に答える 1

0

この小さなスニペットは、Google Apps Script を使用して Google スプレッドシートに関数を作成します。

function emptySpace(array) {
  // set counter
  var counter = 0;

  // itterate through values
  for (i in array){
    if (array[i].length > 1) {
      throw ("Only single column of data");
    } else {
      if(array[i][0] != "") {
        counter++;
      } else {
        break;
      }
    }
  }

  // return value + 1 
  return counter + 1;
}

スクリプト エディターを使用してこのスクリプトをスプレッドシートに追加すると、関数 emptySpace が次のようにワークシート全体で使用可能になります=emptySpace(A1:A7)

私が作成したサンプルファイルを参照してください:空のスペース

于 2013-01-11T19:00:07.710 に答える