Trying to copy a whole spreadsheet but I guess there is no api to do so.
Basically, I am trying to do the following:
- Have a spreadsheet which I would like to duplicate with minor changes.
- Create a new spreadsheet, copy all sheets from a template into the new spreadsheet one by one (Spreadsheet copy would have been much more efficient)
Creating new spreadsheets works alright however, copying sheets from spreadsheet doesn't work.
Tried 2 ways:
Angular:
$http.post("https://sheets.googleapis.com/v4/spreadsheets/"+fromSpreadsheetId+"/sheets/"+fromSheetId,
{headers: {
'Authorization': 'Bearer ' + this.oauthToken
}},
Gives following error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'
Google Sheets Api call:
gapi.client.sheets.spreadsheets.sheets.copyTo({spreadsheetId: fromSpreadsheetId , sheetId: fromSheetId},{destinationSpreadsheetId: destinationSpreadsheetId});
Request goes through without any error. However, the newly created spreadsheet doesn't have the sheet copied.