Writes real .xlsx files (Office Open XML) without any library – compressed with the browser's built-in CompressionStream. Numbers stay numbers, everything else becomes text.

TableApi.downloadExcel exports what the table shows; use the ExcelService directly for any other data.

Example

// all rows, own columns – independent of filter and sorting
const body = tableApi.getBodyModel() as AreaModelObjectArray<Order>;
const matrix = [
["ID", "Customer", "Total"],
...body.getAllRows().map(o => [o.id, o.customer, o.total])
];
await new ExcelService().downloadExcel(matrix, "orders.xlsx", "GuiExpert");

Example

// a Blob instead of a download, e.g. for an upload
const blob = await new ExcelService().createExcelBlob(matrix);

See

Training: Excel export without a library

Hierarchy

  • ExcelService

Implements

Constructors

Methods

  • Creates the .xlsx file as a Blob (compressed), e.g. to upload it instead of downloading it.

    Parameters

    • matrix: any[][]
    • author: string = ''

    Returns Promise<Blob>

    Example

    const blob = await new ExcelService().createExcelBlob([["Name", "City"], ["Ann", "Berlin"]]);
    await fetch("/api/upload", { method: "POST", body: blob });
  • ZIP with DEFLATE (method 8) via the browser's CompressionStream; falls back to stored entries where that is not available. 100,000 rows × 7 columns: ~40 MB stored → a few MB compressed.

    Parameters

    • files: Map<string, string>

    Returns Promise<Uint8Array>

  • Downloads a matrix data as an Excel file.

    Parameters

    • matrix: any[][]

      A 2D array representing the data to be included in the Excel file. Each inner array corresponds to a row in the sheet.

    • Optional filename: string = 'file.xlsx'

      The name of the Excel file to be downloaded. Defaults to 'file.xlsx'.

    • Optional author: string = ''

      The author's name to include as metadata in the Excel file. Optional parameter.

    Returns Promise<void>

    Does not return a value.

    Throws

    Throws an error if the input matrix is not a valid 2D array or if the filename is an empty string.