Google-api-php-client: Get list of sheet

Created on 17 Feb 2020  路  3Comments  路  Source: googleapis/google-api-php-client

How to retrive list of my sheets?
i try using
Google_Service_Sheets::spreadsheets->get(spreadsheet_id, optParams)
but it only return 2 which is:
spreadsheetId & spreadsheetUrl

i want do it like this

question

Most helpful comment

Hello,

Are you trying to retrieve the sheet data along with the spreadsheet? You should be able to set $optParams.includeGridData to true:

$sheets->spreadsheets->get($sheetId, ['includeGridData' => true]);

Alternatively, if you're trying to list all the sheets in your account, you may use the Drive API to list files with a query:

$client = new Google_Client();
$drive = new Google_Service_Drive($client);
$sheetsList = $drive->files->listFiles([
    'q' => "mimeType='application/vnd.google-apps.spreadsheet'",
    'fields' => 'nextPageToken, files(id, name)'
]);

For this latter option, refer to the API reference for a full detailing of available options.

All 3 comments

Hello,

Are you trying to retrieve the sheet data along with the spreadsheet? You should be able to set $optParams.includeGridData to true:

$sheets->spreadsheets->get($sheetId, ['includeGridData' => true]);

Alternatively, if you're trying to list all the sheets in your account, you may use the Drive API to list files with a query:

$client = new Google_Client();
$drive = new Google_Service_Drive($client);
$sheetsList = $drive->files->listFiles([
    'q' => "mimeType='application/vnd.google-apps.spreadsheet'",
    'fields' => 'nextPageToken, files(id, name)'
]);

For this latter option, refer to the API reference for a full detailing of available options.

image
i want to get this sheetname, not spreadsheet file.

i do $sheets->spreadsheets->get($sheetId, ['includeGridData' => true]); but it only return this
image

You can find this value at sheets[sheet_index].properties.title.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mevsme picture mevsme  路  4Comments

usamamashkoor picture usamamashkoor  路  5Comments

upendtu picture upendtu  路  4Comments

artemiusgreat picture artemiusgreat  路  3Comments

DenisSokoloff picture DenisSokoloff  路  5Comments