Besides the QuickStart tutorial - There is almost no examples of Google Sheets v4 with Java.
I'm trying to clear all the cells of a sheet using 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?