Skip to main content

Acquire owner information

This section describes the functions to be used if you want to get the owner from a specific spreadsheet.

Function to use

Spreadsheet.getOwner();

Use getOwner(), which is prepared in the Spreadsheet class.

You may need to authenticate at the first execution because you will access the spreadsheet when execution.

Sample code

/**
* Eligible spreadsheet ID
* https://docs.google.com/spreadsheets/d/〇〇〇/edit part of 〇〇〇
*/
const SPREAD_SHEET_ID = '_______________';

/**
* Returns the owner information of the spreadsheet
*/
const getSpreadSheetOwner = () => {
/** Target spreadsheet */
const ss = SpreadsheetApp.openById(SPREAD_SHEET_ID);

/** Number of sheets on the spreadsheet */
const owner = ss.getOwner();

console.log(owner.getEmail());

return owner;
};

When you execute, the log will display the email address of the target spreadsheet.

The owner information is returned as the User class.

Currently, only email addresses can be obtained from the user class.

If the security policy is not allowed to access the email address, a blank string will be returned.