Question

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?

Was it helpful?

Solution

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...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top