如何检查电子表格中是否存在工作表(按名称检查工作表)或不使用 Google Sheet API。我用过 Google Sheet API v4
.
如果工作表不存在,则创建一个新工作表。
谢谢
最佳答案
最后我找到了解决方案。没有可用的方法来检查电子表格中是否存在工作表。
我已经使用电子表格对象来获取电子表格的所有信息。并使用自定义函数来检查特定的工作表名称是否存在并且它工作正常。
function myArrayContainsWord(array $myArray, $word) {
foreach ($myArray as $element) {
if ($element->title == $word) {
return true;
}
}
return false;
}
$service = new Google_Service_Sheets($client);
$spreadsheetId = 'your spredsheetid';
$sheetInfo = $service->spreadsheets->get($spreadsheetId);
$allsheet_info = $sheetInfo['sheets'];
$idCats = array_column($allsheet_info, 'properties');
if (myArrayContainsWord($idCats, "sheetname")) {
//echo found
}
关于php - 检查表是否存在于电子表格 Google 电子表格 API PHP 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44940667/