How to get Sheet Name of individual Sheets in Google Spreadsheet - Google Sheet Api v4 - Java

≯℡__Kan透↙ 提交于 2019-12-13 19:21:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!