• Creates a new sheet within an existing Google Sheets spreadsheet.

    This function uses the Google Sheets API to create a new sheet within a specified spreadsheet. It requires the spreadsheet ID where the new sheet will be added and the title for the new sheet. The function assumes that the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable is set with the path to the Google service account credentials JSON file.

    Set up the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable: export GOOGLE_APPLICATION_CREDENTIALS=path_to_your_credentials.json

    Parameters

    • spreadsheetId: string

      The ID of the Google Sheets spreadsheet where the new sheet will be added.

    • sheetTitle: string

      The title for the new sheet.

    Returns Promise<CreateNewSheetResponse>

    • A promise that resolves with the response from the Google Sheets API after the new sheet is created.

    Throws

    • Throws an error if there is an issue with creating the new sheet.

    Example

    const spreadsheetId = 'your_spreadsheet_id_here';
    const sheetTitle = 'New Sheet Title';
    (async () => {
    try {
    const response = await createNewSheet(spreadsheetId, sheetTitle);
    console.log('New Sheet Created:', response);
    } catch (error) {
    console.error(error);
    }
    })();

Generated using TypeDoc