Skip to content

Function: parseWorkbook()

ts
function parseWorkbook(workbook: Workbook, headerRow?: number): Promise<Record<string, {
  headers: string[];
  data: Cell[][];
}>>;

Defined in: src/excel/excel.tsx:223

Parse a workbook and extract headers and data from each sheet.

Parameters

ParameterTypeDefault valueDescription
workbookWorkbookundefinedThe ExcelJS workbook to parse.
headerRownumber1The row number used as the header. Defaults to 1.

Returns

Promise<Record<string, { headers: string[]; data: Cell[][]; }>>

An object keyed by sheet name. Each value has headers (string array) and data (2D Cell array).

Example

ts
const workbook = await mwFileToWorkbook(file);
const parsed = await parseWorkbook(workbook, 2);
console.log(parsed['Orders'].headers);

Matterway Assistant SDK Documentation