我在 Google Drive 上有一个电子表格,我正在使用 PHP API ( https://developers.google.com/sheets/api/guides/values )更新内容。
我将我的项目的报告存储在这里。每个项目都有自己的工作表。
当项目没有工作表(新项目)时,我为该项目创建一个新工作表,并以新项目的名称命名。
工作表是作为最后一张创建的。
这是我当前创建新工作表的代码:
$body = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(
['requests' => ['addSheet' => ['properties' => ['title' => $project_name]]]]
);
$result = $service->spreadsheets->batchUpdate($spreadsheetId, $body);
我想按字母顺序排列工作表。不包括第一张表,哪里有一些全球统计数据。
有什么方法可以使用 Google SpreadSheet API 更改工作表的顺序?
我刚刚找到了解决方案;-)
$requests = [
new Google_Service_Sheets_Request([
'updateSheetProperties' => [
'fields' => 'index',
'properties' => [
'sheetId' => $sheet_id,
'index' => $i,
],
],
])
];
$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
'requests' => $requests
]);
$result = $service->spreadsheets->batchUpdate($spreadsheetId, $batchUpdateRequest);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句