UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

47 lines (46 loc) 2.15 kB
import { aw as y, w as C } from "./Dm24M4tfHrPDHOCg.js"; /** * @license @sheetxl/studio-vanilla - SheetXL Studio - Vanilla entry point for integrating SheetXL UI. - v0.6.4 * * (C) 2025-present SheetXL Inc. & Michael T. Ford * License: The license can be found at https://www.sheetxl.com/license. */ const k = async (a, p) => { const { trimLeadingBlankRow: i = !0, trimLeadingBlankColumn: f = !0, excludeHidden: m = !1, sheetKey: r = null, papaParseConfig: w = {} } = p || {}, u = await import("./B6M04wH6vpX8Tswo.js").then((s) => s.p); if (!a) throw new Error("workbook must be specified"); let t = null; if (r === null ? t = a.getSelectedSheet() : typeof r == "number" ? t = a.getSheets().getItems()[r] : typeof r == "string" && (t = a.getSheets().getByName(r)), !t) throw new Error("invalid sheetKey specified"); let d = null; const c = []; let e = null, n = t.getUsedRange({ excludeHidden: m }); if (!n) throw new Error("Nothing to export"); if (!i || !f) { const s = i ? n.getRowStart() : 0, l = f ? n.getColumnStart() : 0; n = n.getOffsetTo(s, l); } n.forEach((s, l) => { const h = l.getCoords(), x = l.getCell(); d !== h.rowIndex && (e && c.push(e), e = [], d = h.rowIndex); const S = x.toTextUnformatted() ?? ""; e.push(S); }, { includeEmpty: !0, address: null }), e && c.push(e); const o = { ...w }, g = u.unparse(c, o); return new TextEncoder().encode(g).buffer; }, b = async (a, p) => { const { papaParseConfig: i, setValuesOptions: f, createWorkbookOptions: m } = p ?? {}, r = await import("./B6M04wH6vpX8Tswo.js").then((o) => o.p), w = new TextDecoder().decode(a); let u = -1; const t = new y(m), d = t.getSelectedSheet().getEntireRange().startIncrementalUpdates({ orientation: C.Orientation.Row }), c = p?.onProgress; let e = 0; const n = { ...i, transform: (o, g) => { i?.transform && (o = i.transform(o, g)); const s = g; s === 0 && u++; let l = o ?? ""; return d.pushAt(u, s, l), e++, e % 1e5 == 0 && c?.(e), o; } }; return r.parse(w, n).data, d.apply({ textParser: !0, ...f }), t; }; export { b as fromBufferCSV, k as toBufferCSV };