Skip to main content

Acquisition of theme

This section describes how to get language setting information from a specific spreadsheet.

function to use

Spreadsheet.getSpreadsheetTheme();

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

The return value is returned as the SpreadsheetTheme class.

From this class, you can get fonts and colors of the theme by using getFontFamily() and getThemeColors().

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 the 〇〇〇
*/
const SPREAD_SHEET_ID = '_______________';

/**
* Return the language setting information of the spreadsheet
*/
const getSheetTheme = () => {
/** Target spreadsheet */
const ss = SpreadsheetApp.openById(SPREAD_SHEET_ID);

/** Theme information */
const theme = ss.getSpreadsheetTheme();

console.log(theme.getFontFamily());
console.log(theme.getThemeColors());

return theme;
};

When executed, the spreadsheet theme is returned.

The log outputs the font family and color used for the theme.