Reading whole Google Spreadsheet with Sheets API v4 Java

19,371

You can specify the whole Sheet as just : String range = "Class Data";, for a Sheet named Class Data. You can see the output on the Try it part of the spreadsheets.values.get reference.

Share:
19,371

Related videos on Youtube

Michael Meyer
Author by

Michael Meyer

Updated on February 12, 2022

Comments

  • Michael Meyer
    Michael Meyer over 2 years

    I would like to read a Google Spreadsheet like described in the Java Quickstart

    https://developers.google.com/sheets/quickstart/java

    The Quickstart explaines how to read data from a give range

    .....
    String range = "Class Data!A2:E";
    ValueRange response = service.spreadsheets().values()
            .get(spreadsheetId, range)
            .execute();
    
    List<List<Object>> values = response.getValues();
    ....
    

    But I have the problem that I do not know the Range of the Spreadsheet. The number of columns can change. So how can I read for example all the data of the Sheet without knowing the range?

    Regards

    Michael

  • William Entriken
    William Entriken almost 7 years
    So sad that Google does not properly document ranges.
  • Nico Jones
    Nico Jones almost 4 years
    Actually, they don't properly document any API I have used so far...
  • humble
    humble about 3 years
    how would it work if I only know the sheet id and not the sheet name?