问题
I am trying to get sheet name of individual sheets in Google Spreadsheet using Google Sheet Api v4.
I tried the following way that gets the properties:
Spreadsheet response1= service.spreadsheets().get(spreadsheetId).setIncludeGridData (false).execute ();
System.out.println (response1.getProperties ().getTitle ());
However it displays the name of the actual Spreadsheet rather than displaying the names of individual sheets in the Spreadsheet.
Do anyone know how we can go about it?
回答1:
Below is the answer to above question:
Spreadsheet response1= service.spreadsheets().get(spreadsheetId).setIncludeGridData (false)
.execute ();
System.out.println (response1.getSheets ().get (0).getProperties ().getTitle ());
Thank you.
回答2:
Here, you can iterate over the workSheetList
to get all individual sheet title.
Spreadsheet response1= service.spreadsheets().get(spreadsheetId).setIncludeGridData (false).execute ();
List<Sheet> workSheetList = response1.getSheets();
for (Sheet sheet : workSheetList) {
System.out.println(sheet.getProperties().getTitle());
}
来源:https://stackoverflow.com/questions/38123383/how-to-get-sheet-name-of-individual-sheets-in-google-spreadsheet-google-sheet