【问题标题】:Get title of Spreadsheet Google Spreadsheet api PHP获取电子表格 Google 电子表格 api PHP 的标题
【发布时间】:2021-07-30 14:59:39
【问题描述】:

我正在尝试获取电子表格名称。但它不起作用。任何人都可以帮助我吗? 我正在使用 php 和 Google 电子表格以及 google drive api:

function getSheetTitle($spreadsheetID){
    $client = new \Google_Client();
    $client->setApplicationName('Sheets');
    $client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
    $client->setAccessType('offline');
    $client->setAuthConfig(GOOGLE_CREDENTIALS);
    
    $client = GoogleClientSheet();
    $service = new Google_Service_Sheets($client);
    
    $worksheetSheets = $service->spreadsheets->get($spreadsheetID);
    return $worksheetSheets->getTitle();
}

【问题讨论】:

    标签: php google-sheets google-api google-sheets-api


    【解决方案1】:

    只需添加 getProperties()->getTitle()

    function getSheetTitle($spreadsheetID){
        $client = new \Google_Client();
        $client->setApplicationName('Sheets');
        $client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
        $client->setAccessType('offline');
        $client->setAuthConfig(GOOGLE_CREDENTIALS);
        
        $client = GoogleClientSheet();
        $service = new Google_Service_Sheets($client);
        
        $worksheetSheets = $service->spreadsheets->get($spreadsheetID);
        return $worksheetSheets->getProperties()->getTitle();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      • 1970-01-01
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      相关资源
      最近更新 更多