UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

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