문제

I'm updating a google spreadsheet and it takes about 30 seconds to update 100 cells. I'm using the code described in the answer in the following question Is this normal? This just seem to be horribly slow and nearly impossible to work with. Are there any options out there to speed up this process?

도움이 되었습니까?

해결책

The answer was in the provided link
I changed:

  private CellEntry createUpdateOperation(URL cellFeedUrl, int row, int col, String value) throws ServiceException, IOException {
    String batchId = "R" + row + "C" + col;
    URL entryUrl = new URL(cellFeedUrl.toString() + "/" + batchId);
    CellEntry entry = this.service.getEntry(entryUrl, CellEntry.class);
    entry.changeInputValueLocal(value);
    BatchUtils.setBatchId(entry, batchId);
    BatchUtils.setBatchOperationType(entry, BatchOperationType.UPDATE);
    return entry;
  }

into:

  private CellEntry createUpdateOperation(URL cellFeedUrl, int row, int col, String value) throws ServiceException, IOException {
    String batchId = "R" + row + "C" + col;
    CellEntry batchEntry = new CellEntry(row, col, value);
    batchEntry.setId(String.format("%s/%s", cellFeedUrl.toString(), batchId));
    BatchUtils.setBatchId(batchEntry, batchId);
    BatchUtils.setBatchOperationType(batchEntry, BatchOperationType.UPDATE);
    return batchEntry;
  }

300 cells edited in +/-20 seconds now so it's better...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top