modern-xlsx API Reference - v1.3.0
    Preparing search index...

    Function sheetToJson

    • Convert a Worksheet to an array of JSON objects.

      By default, the first row (at or after the start of range) is the header row. Pass header: 'A' to use column letters as keys.

      Type Parameters

      • T extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • ws: Worksheet

        The Worksheet to convert.

      • Optionalopts: SheetToJsonOptions

        Options for header mode, range, default value, and row limit.

      Returns T[]

      An array of objects where keys are header names and values are cell values.

      const data = sheetToJson(ws);
      console.log(data[0]); // { Name: 'Alice', Score: 95 }