Tag: google sheets api

Java | 如何使用API​​在Google电子表格范围内查找值(行号和列号)?

我正在使用Java API(V4)从谷歌工作表中读取和编辑数据。 到目前为止,我能够根据行号和列号(索引)读取和编辑数据。 我想要做的是按照其特定值本地化数据(我想使用其值获取特定单元格的行和列号)。 到目前为止,这是我用来编辑数据的工作代码的一部分: // Copy the format from A1:C1 and paste it into A2:C5, so the data in // each column has the same background. requests.add(new Request() .setCopyPaste(new CopyPasteRequest() .setSource(new GridRange() .setSheetId(0) .setStartRowIndex(0) .setEndRowIndex(1) .setStartColumnIndex(0) .setEndColumnIndex(3)) .setDestination(new GridRange() .setSheetId(0) .setStartRowIndex(1) .setEndRowIndex(6) .setStartColumnIndex(0) .setEndColumnIndex(3)) .setPasteType(“PASTE_FORMAT”))); BatchUpdateSpreadsheetRequest batchUpdateRequest = new BatchUpdateSpreadsheetRequest() .setRequests(requests); 谁能帮帮我吗? 先感谢您。

使用Google表格API和服务帐户时禁止使用403

我有一个使用服务帐户的应用程序(因为它从一个cron作业运行,因此我无法通过浏览器中的用户进行授权)。 以下是我创建工作表服务的方法: private static final String APPLICATION_NAME = “my app”; private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); private static HttpTransport HTTP_TRANSPORT; static { try { HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); } catch (GeneralSecurityException | IOException e) { e.printStackTrace(); } } private static final List SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS); private static Credential authorize() throws IOException, GeneralSecurityException { GoogleCredential credential […]

使用Java通过API写入GoogleSheet

我正在尝试使用带有Java的Google Sheet API将值写入单元格。 为了阅读,我使用了Java Quickstart的指南 ,它对我来说很好。 要写入Google表格,我使用: service.spreadsheets().values().update(spreadsheetId, “Sheet1!A4:H”, response).execute(); 运行时此函数输出以下错误: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden { “code” : 403, “errors” : [ { “domain” : “global”, “message” : “Request had insufficient authentication scopes.”, “reason” : “forbidden” } ], “message” : “Request had insufficient authentication scopes.”, “status” : “PERMISSION_DENIED” } 作为我正在使用的身份validation范围 private static final List SCOPES = […]

将OAuth 2.0和Google Spreadsheet API与Jav​​a结合使用的示例是什么?

示例代码在哪里显示如何使用Google Data Java Client Library及其对OAuth 2.0支持与Google Spreadsheet API (现在称为Google Sheets API )?

使用Google Sheet API V4将数据写入Google表格 – Java示例代码

我有一个开发的测试自动化框架,可以在excel表中为测试用例写入通过或失败值。 我们已决定迁移到Google表格。 任何人都可以提供一个示例Java代码,使用Google Sheet API V4将数据写入Google表格吗? 我有一个表格文件,但目前尚不清楚。 谢谢。