[英]Google Sheets V4 Java - clear a sheet
Besides the QuickStart tutorial - There is almost no examples of Google Sheets v4 with Java. 除了快速入门教程之外-几乎没有Java谷歌表格v4的示例。
I'm trying to clear all the cells of a sheet using batchUpdate
. 我正在尝试使用batchUpdate
清除工作表的所有单元格。
I read I need to add no values in order for it to remove all cells but it does nothing: 我读到我不需要添加任何值才能删除所有单元格,但是它什么也不做:
public void clearSheet(String sheetName) {
try {
// Build a new authorized API client service.
Sheets service = GoogleApi.getInstance().getSheetsService();
String spreadsheetId = GoogleSheetsSettings.getDataFileId();
BatchUpdateValuesRequest oRequest = new BatchUpdateValuesRequest();
oRequest.setValueInputOption("RAW");
//oRequest.setData(oList);
BatchUpdateValuesResponse oResp1 = service.spreadsheets().values().batchUpdate(spreadsheetId, oRequest).execute();
} catch (IOException ex) {
Logger.getLogger(GoogleApi.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Could not execute spreadsheet update");
}
}
What is the right approach? 什么是正确的方法?
工作的是:
service.spreadsheets().values().clear(spreadsheetId, range, new ClearValuesRequest()).execute()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.