我们正在使用 Google Sheets API V4。我们希望从 v4 开始添加 100 万行,我们支持在电子表格中写入 200 万个单元格。因此,我们尝试添加 80,000 行 6 列。80,000 * 6 = 480000 细胞,但我们得到以下错误。
{
"code": 400,
"errors": [
{
"domain": "global",
"message": "Invalid requests[0].appendCells: This action would increase the number of cells in the workbook above the limit of 2000000 cells.",
"reason": "badRequest"
}
],
"message": "Invalid requests[0].appendCells: This action would increase the number of cells in the workbook above the limit of 2000000 cells.",
"status": "INVALID_ARGUMENT"
}
我们每次循环 80 时添加 1000 行。错误后我们检查工作表,发现插入了 73000 行。
我们认为 Google Sheets API 也会计算第 6 列之后的空单元格。假设我们用铰孔计算 73000 * 26 (AZ) = 1898000,当我们尝试添加更多时,我们得到了错误。
请帮助我们提出任何建议如何去除铰孔空单元或任何其他替代方案。我们正在使用以下代码
AppendCellsRequest appendCellReq = new AppendCellsRequest();
appendCellReq.setSheetId(ssDetails.getSheets().get(4).getProperties().getSheetId());
appendCellReq.setRows(listRowData);
appendCellReq.setFields("userEnteredValue");
Request request = new Request();
request.setAppendCells(appendCellReq);
List<Request> requests = new ArrayList<>();
requests.add(request);
BatchUpdateSpreadsheetRequest batchRequests = new BatchUpdateSpreadsheetRequest();
batchRequests.setRequests(requests);
service.spreadsheets().batchUpdate(spreadsheetId, batchRequests).execute();
第二件事,在附加单元格时,我们无法确定单元格的列位置,它总是从第一列(A)开始。