copyTo method

Future<bool> copyTo(
  1. String spreadsheetId
)

Copies this Worksheet to another spreadsheet (the name of the copy will be "Copy of title").

spreadsheetId - destination spreadsheet id.

Provided credentialsJson has to have permission to spreadsheetId.

Returns Future true in case of success.

Throws GSheetsException.

Implementation

Future<bool> copyTo(String spreadsheetId) async {
  if (spreadsheetId.isEmpty || spreadsheetId == this.spreadsheetId) {
    throw GSheetsException('invalid spreadsheetId ($spreadsheetId)');
  }

  final response = await _client.post(
    '$_sheetsEndpoint${this.spreadsheetId}/sheets/$id:copyTo'.toUri(),
    body: jsonEncode({'destinationSpreadsheetId': spreadsheetId}),
  );
  checkResponse(response);
  return response.statusCode == 200;
}