Function getWorksheetIndex

  • Gets the index of a worksheet by name or RegExp pattern.

    Parameters

    • workbook: Workbook

      The ExcelJS workbook instance.

    • query: string | RegExp

      The worksheet name or pattern to search for.

    Returns number

    The index of the worksheet or -1 if not found.

    const index = getWorksheetIndex(workbook, 'Sheet1');
    const index = getWorksheetIndex(workbook, /Data/);