1
クイックスタートチュートリアルの他に、GoogleスプレッドシートにはJavaを使用した例はほとんどありません。GoogleスプレッドシートV4 Java - シートを消去
batchUpdate
を使用してシートのすべてのセルを消去しようとしています。
私はそれがすべての細胞を除去するためには値を追加する必要がありませんが、それは何もしません読み:
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");
}
}
正しいアプローチは何ですか?
[ '方法:spreadsheets.values.clear']これをチェックしてみてください(https://developers.google.com/sheets/api/reference/rest/v4を/spreadsheets.values/clear)それがあなたを助けることができるなら。スプレッドシートから値をクリアします。呼び出し元はスプレッドシートのIDと範囲を指定する必要があります。値のみがクリアされます。セルのその他のプロパティ(フォーマット、データ検証など)はすべて保持されます。詳細については、この[SOの質問](http://stackoverflow.com/questions/37928947/)をチェックしてください。 – KENdi