Cover Photo by Manuel Compana

Reading From Sheets During a Batch Job

Setting up the Service Account

Reading Sheets data using the Java SDK

InputStream in = GoogleAPI.class.getResourceAsStream("/google-sheets-client-secret.json"); 
GoogleCredential credential = GoogleCredential.fromStream(in); List<String> scopes = Arrays.asList(SheetsScopes.SPREADSHEETS);
credential = credential.createScoped(scopes);
Sheets sheets = Sheets.Builder(          GoogleNetHttpTransport.newTrustedTransport(),           GsonFactory.getDefaultInstance(), credential)          .setApplicationName("foobar")
.build();
BatchGetValuesResponse response = sheets.spreadsheets().values()
.batchGet(SPREADSHEET_ID)
.setRanges(Arrays.asList("A1:A"))
.execute();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aymen Furter

I am a Cloud Solution Architect working for Microsoft. The views expressed on this site are mine alone and do not necessarily reflect the views of my employer.