Skip to content

Function: parseWorkbook()

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

Defined in: packages/excel-tools/lib/excel.d.ts:110

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

Parameters

ParameterTypeDescription
workbookWorkbookThe ExcelJS workbook to parse.
headerRow?numberThe 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