Get all sheets names

Created on 15 February 2023, almost 2 years ago
Updated 12 April 2023, over 1 year ago

Problem/Motivation

Add a method to list all the sheet names and ids of a spreadsheet

Proposed resolution

Something like this:

public function getSheets() {
    $client = $this->client;
    $service = new \Google_Service_Sheets($client);
    $sheets = $service->spreadsheets->get($this->sheetId)->sheets;

    $sheets_array = [];
    foreach ($sheets as $sheet) {
      $id = $sheet->properties['sheetId'];
      $name = $sheet->properties['title'];
      $sheets_array[$id] = $name;
    }

    return $sheets_array;
}
Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇵🇹Portugal jmauricio

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024