Google sheets 如何在不使用批处理的情况下,使用Sheets API将单个单元格添加到Google电子表格中?
两年半前有人问了一个问题,但没有回答 我已经研究了使用批更新修改单元格和添加单元格。然而,我试图在不使用批处理机制的情况下添加一个单元格,而且似乎没有记录在案的方法 这是我试过的。请注意,我尝试添加的条目当前没有值,这就是链接文档不允许我“更改”单元格内容的原因。特别是,Google sheets 如何在不使用批处理的情况下,使用Sheets API将单个单元格添加到Google电子表格中?,google-sheets,google-spreadsheet-api,Google Sheets,Google Spreadsheet Api,两年半前有人问了一个问题,但没有回答 我已经研究了使用批更新修改单元格和添加单元格。然而,我试图在不使用批处理机制的情况下添加一个单元格,而且似乎没有记录在案的方法 这是我试过的。请注意,我尝试添加的条目当前没有值,这就是链接文档不允许我“更改”单元格内容的原因。特别是,CellFeed并不包含我试图添加到的值中的单元格 CellEntry otherEntryFromCellFeed = // Obtained through OAuth and then finding a sheet
CellFeed
并不包含我试图添加到的值中的单元格
CellEntry otherEntryFromCellFeed = // Obtained through OAuth and then finding a sheet, a worksheet, and a cellFeed, documented above
CellEntry cellEntry = new CellEntry(5, 10, "Value");
cellEntry.setService(otherEntryFromCellFeed.getService());
cellEntry.update();
错误:
Exception in thread "main" java.lang.UnsupportedOperationException:
Entry cannot be updated at
com.google.gdata.data.BaseEntry.update(BaseEntry.java:635)
在又一个小时的Javadocs搜索之后,最终我发现
insert
方法也适用于cell提要,它使用了来自未完成文档的cellFeedUrl
CellEntry cellEntry = new CellEntry(5, 10, "Value");
service.insert(cellFeedUrl, cellEntry);