Skip to content

Example: 100k-Row Export ​

Large exports are what the Fast stream path is built for: 100k rows run in a Worker in the browser (the main thread only does one structured clone), with Fast stream finishing in ~0.8s.

Mock data preview ​

Mock · 3 rows · seed 42
Order IDDateRegionProductChannelQtyUnit PriceAmountStatus
ORD-0000012026-07-21华东USB-C 扩展坞线上18789.4414209.92pending
ORD-0000022026-07-28西南显示器支架线上51127.475637.35paid
ORD-0000032026-07-15东北机械键盘线下1898.61898.61paid

Implementation ​

ts
import { exportExcel } from "@marcusok/excel-exporter";

// rows: sales data from your business layer, fields matching the columns
// below (fetching is omitted here; the scenario uses 100k rows — the live
// demo generates mock data for the same sales scenario, with more columns)

const result = await exportExcel({
  filename: "large-export-100k",
  sheets: [
    {
      name: "Sales",
      columns: [
        { prop: "orderId", label: "Order ID", width: 18 },
        { prop: "date", label: "Date", width: 12 },
        { prop: "amount", label: "Amount", width: 14 },
        { prop: "status", label: "Status", width: 10 },
      ],
      data: rows,
    },
  ],
  mode: "auto", // ≥ 50k rows -> worker + stream
  onProgress: (p) => setProgress(p),
});

console.log(result); // engine: "modern-xlsx", mode: "stream", rowCount: 100000

Notes ​

  • At 100k rows auto picks worker + Fast stream: ~0.8s measured (vs 17.5s on the Workbook path);
  • The stream path supports multi-row headers and merges, but does not support styles/width/freeze/filter; a console warning is expected;
  • onProgress reports every 1000 rows;
  • Set decimals explicitly on numeric columns for value consistency with the Workbook path.

Compare auto vs main at 100,000 rows in the play.