Skip to content

Function: parseWorkbook()

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

Defined in: packages/sdk/src/excel/excel.tsx:226

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, { data: Cell[][]; headers: string[]; }>>

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