如何获取Google电子表格中单个表格的表名 - Google Sheet Api v4 - Java

问题描述:

我尝试使用Google Sheet Api v4获取Google电子表格中单个工作表的名称。

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?

以下是上述问题的答案:

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 ());

谢谢。