【问题标题】:Google Sheet API - How to copy/paste an entire sheet to another spreadsheet?Google Sheet API - 如何将整个工作表复制/粘贴到另一个电子表格?
【发布时间】:2021-02-15 12:58:41
【问题描述】:

我有一个生产电子表格和一个开发电子表格。

我需要将第一张生产文件复制到开发文件中。

我无法理解copyTo 的用法,因为无法设置目的地。

如何将一张纸从一张纸复制到另一张纸上?

重要

我正在使用 PHP !

【问题讨论】:

  • 当我从google-apps-script, google-sheets, google-sheets-api 的标签中看到您的问题时,我了解到您希望使用带有 Google Apps 脚本的 Sheets API 来实现您的目标。但是,现在我注意到,从您当前的问题和标签中,我了解到我提出的答案对您的问题没有用处。所以我必须删除我的答案。对此我深表歉意。

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


【解决方案1】:

由于您使用的是 PHP,请参考Google Sheets PHP Quickstart 了解如何在 PHP 中设置和使用 Google Sheets API。

使用spreadsheets.sheets.copyTo将工作表复制到不同电子表格的示例代码:

  $service = new Google_Service_Sheets($client);
  $requestBody = new Google_Service_Sheets_CopySheetToAnotherSpreadsheetRequest();
  $requestBody->setDestinationSpreadsheetId($destinationSpreadsheetId);
  $response = $service->spreadsheets_sheets->copyTo($originalSpreadsheet, $sheetId, $requestBody);

说明:

其他参考:

【讨论】:

  • 你在哪里找到了setDestinationSpreadsheetId()的使用记录?
  • 这里 Google Sheets API PHP reference documentation 它包含所有用于 php 的工作表 api 类
  • 嗯,好的,文档,但没有示例。 Google 提供的错误文档
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-21
  • 2010-10-30
  • 1970-01-01
  • 1970-01-01
  • 2016-10-06
  • 2020-04-09
  • 1970-01-01
相关资源
最近更新 更多