SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface WriteRequest

    The request passed to IWorkbookIO.IBackingStore.write.

    The store receives the destination as an IWorkbookIO.Origin handle — never a fileName-vs-provenance ambiguity. Its contract:

    • bound + writable origin → persist to it silently (no dialog), unless prompt. Update its stat state (the written size) and return it.
    • unbound or read-only origin, or prompt → resolve a destination itself (a save picker in the browser; a suggested name in Node), using suggestedName for any prompt/default, and mint a new origin for it — passing that origin to encode — then return the new origin. The request's origin is never changed: it keeps naming its own file. For a save, the IO layer then moves the workbook to the origin returned.
    • Refuse (throw) a destination another open workbook saves back to — other than this workbook's own.
    interface WriteRequest {
        encode: (
            format?: string,
            origin?: IWorkbookIO.Origin,
        ) => Promise<ArrayBufferLike | null>;
        format: FormatType;
        origin: IWorkbookIO.Origin;
        prompt?: boolean;
        suggestedName: string;
        workbook: IWorkbook;
    }
    Index
    encode: (
        format?: string,
        origin?: IWorkbookIO.Origin,
    ) => Promise<ArrayBufferLike | null>

    Encodes the workbook to bytes using the resolved format, or an alternate format key.

    Type Declaration

      • (format?: string, origin?: IWorkbookIO.Origin): Promise<ArrayBufferLike | null>
      • Parameters

        • Optionalformat: string

          An alternate format key — the one the user picked, for a resolved destination.

        • Optionalorigin: IWorkbookIO.Origin

          The origin being written, when the store minted one for a destination it resolved. Omitted, it is origin. The caller's onWarnings sees this as the destination.

        Returns Promise<ArrayBufferLike | null>

        The bytes to persist, or null when the caller declined the write through WriteOptions.onWarnings. A store that receives null persists nothing and returns null — the same outcome as a dismissed save dialog.

    Call this after resolving the destination (e.g. once a Save picker / permission prompt has returned). The first invocation also fires the caller's ITaskProgress.onStart, so encoding before the prompt resolves would show progress UI on top of the dialog. A store that is cancelled should return without calling encode, so onStart never fires for it.

    format: FormatType

    The resolved write format (consumer chrome — encoding runs through encode).

    The destination handle: the workbook's own origin for a save, the target for a Save As or an export. May be unbound (getPath() null) — see the store contract above.

    prompt?: boolean

    Resolve a destination even when origin is bound and writable — see WriteAsOptions.prompt, whose value this carries. A store that cannot ask ignores it.

    suggestedName: string

    A suggested file name (with extension) for any destination prompt or default.

    workbook: IWorkbook

    The workbook being written.