Search code examples
google-apps-scriptgoogle-sheetsgoogle-cloud-platform

Is there a way to copy from a Google Sheets that is copy locked?


The owner of a Google Sheets can tick off the option: "Viewers and commenters can see the option to download, print, and copy". However in this option, Google does not explicitly say that viewers cannot copy.

How are they able to copylock a spreadsheet and is there a way to bypass and copy anyway?

Here is a test spreadsheet:
https://docs.google.com/spreadsheets/d/1DLeK4X4MFbQe6X6lcbE_O-rTdy3MHApZEu1HhUWIji4/edit#gid=0


Solution

  • You are not able to directly copy the sheet, but there are a couple workarounds:

    1. Copy cells values from the formula bar. (If the cell has a formula, it will copy the formula,not the actual value).

    2. Copy values to another document using formula or Google Apps Script.

    Formula

    importrange("YOUR-ID","Sheet1!B2")
    

    Script

    function getData() {
      var data = SpreadsheetApp.openById("YOUR-ID").getSheets()[0].getRange("B2").getValue();
      console.log(data);
    }