Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
How to get list of Sheet's via Google V4 Java API

I'm trying to get a list of sheet names via the google API.

I can get cell values, but I can't find out how to get the list of sheets.

Here is the code I've tried.

Credential credential = authorize();
Sheets service = new Sheets.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME).build();

System.out.println("__");
Set<Entry<String, Object>> entrySet = service.spreadsheets().get(spreadsheetId).entrySet();
for (Entry<String, Object> entry : entrySet) {
   System.out.println(entry.getKey() +"    " + entry.getValue());
} 
System.out.println("__");

System.out.println("1::" + service.spreadsheets().get(spreadsheetId).get("spreadsheetId"));
System.out.println("2::" + service.spreadsheets().get(spreadsheetId).get(spreadsheetId));
System.out.println("3::" + service.spreadsheets().get(spreadsheetId).get("sheet"));
System.out.println("4::" + service.spreadsheets().get(spreadsheetId).get("accesToken"));
System.out.println("5::" + service.spreadsheets().get(spreadsheetId).get("properties"));
System.out.println("6::" + service.spreadsheets().get(spreadsheetId).get("sheets"));
System.out.println("7::" + service.spreadsheets().get(spreadsheetId).get("sheets[]"));

Here is the output

__
spreadsheetId    1iV5qliFI8xNhqyLJoOBTQxxxxxxxxxxxxxxxxxx
__
1::1iV5qliFI8xNhqyLJoOBTQxxxxxxxxxxxxxxxxxx
2::null
3::null
4::null
5::null
6::null
7::null

My pom.xml entries

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.22.0</version>
</dependency>
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client-jetty</artifactId>
    <version>1.22.0</version>
</dependency>
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-sheets</artifactId>
    <version>v4-rev471-1.22.0</version>
</dependency>

Can anyone suggest how I get the list of sheets in the spreadsheet please.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It's pretty un-intuitive TBH. I had to dig quite a bit in the API to get the hang of it, but with the following you can get the Sheets:

Sheets service = getSheetsService();
Spreadsheet sp = service.spreadsheets().get(spreadsheetId).execute();
List<Sheet> sheets = sp.getSheets();

So the gist is calling execute().

Afterwards, you can access sheet.getProperties().getTitle() to read the title.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda