API 参考

Blob & File

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。
Packages@univerjs/core

This class should not be instantiated directly. Use factory methods on univerAPI instead.

Overview

@univerjs/core

MethodDescription
copyBlobReturns a copy of this blob
extend-
get-
getAsReturn the data inside this object as a blob converted to the specified content type
getBytesGets the data stored in this blob
getContentTypeGets the content type of the data stored in this blob
getDataAsString-
onBeforeRedo-
onBeforeUndo-
onReady-
onRedo-
onRendered-
onStarting-
onSteady-
onUndo-
rectangleAccess rectangle helper utilities
setBytesSets the data stored in this blob
setContentTypeSets the content type of the data stored in this blob
setDataFromString-
toolsAccess common helper utilities

APIs

Getters & Queries

rectangle

Access rectangle helper utilities.

Signature

TypeScript
get rectangle(): typeof Rectangle

Returns

  • typeof Rectangle — Rectangle helper utilities exposed through univerAPI.Util.rectangle.
Source: @univerjs/core

tools

Access common helper utilities.

Signature

TypeScript
get tools(): typeof Tools

Returns

  • typeof Tools — Common helper utilities exposed through univerAPI.Util.tools.
Source: @univerjs/core

get

Signature

TypeScript
static get(): FUtil

Returns

  • FUtil — See signature above.
Source: @univerjs/core

getAs

Return the data inside this object as a blob converted to the specified content type.

Signature

TypeScript
getAs(contentType: string): FBlob

Parameters

  • contentType stringNo description

Returns

  • FBlob — a new blob by converting the current blob to the specified content type

Examples

TypeScript
const blob = univerAPI.newBlob();const newBlob = blob.getAs('text/plain');console.log(newBlob);
Source: @univerjs/core

getBytes

Gets the data stored in this blob.

Signature

TypeScript
getBytes(): Promise<Uint8Array>

Returns

  • Promise<Uint8Array<ArrayBufferLike>> — the blob content as a byte array

Examples

TypeScript
const blob = univerAPI.newBlob();const bytes = await blob.getBytes();console.log(bytes);
Source: @univerjs/core

getContentType

Gets the content type of the data stored in this blob.

Signature

TypeScript
getContentType(): string | undefined

Returns

  • string — the content type

Examples

TypeScript
const blob = univerAPI.newBlob();const contentType = blob.getContentType();console.log(contentType);
Source: @univerjs/core

getDataAsString

Signature

TypeScript
getDataAsString(charset?: string): Promise<string>

Parameters

  • charset string (optional)No description

Returns

  • Promise<string> — See signature above.
Source: @univerjs/core

Setters & Modifiers

setBytes

Sets the data stored in this blob.

Signature

TypeScript
setBytes(bytes: Uint8Array): FBlob

Parameters

  • bytes Uint8Array<ArrayBufferLike>No description

Returns

  • FBlob — the blob object

Examples

TypeScript
const blob = univerAPI.newBlob();const bytes = new Uint8Array(10);blob.setBytes(bytes);
Source: @univerjs/core

setContentType

Sets the content type of the data stored in this blob.

Signature

TypeScript
setContentType(contentType: string): FBlob

Parameters

  • contentType stringNo description

Returns

  • FBlob — the blob object

Examples

TypeScript
const blob = univerAPI.newBlob();blob.setContentType('text/plain');
Source: @univerjs/core

setDataFromString

Signature

TypeScript
setDataFromString(data: string, contentType?: string): FBlob

Parameters

  • data stringNo description
  • contentType string (optional)No description

Returns

  • FBlob — See signature above.
Source: @univerjs/core

Actions & Operations

copyBlob

Returns a copy of this blob.

Signature

TypeScript
copyBlob(): FBlob

Returns

  • FBlob — a new blob by copying the current blob

Examples

TypeScript
const blob = univerAPI.newBlob();const newBlob = blob.copyBlob();console.log(newBlob);
Source: @univerjs/core

Events

onBeforeRedo

Deprecated — use univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onBeforeRedo(callback: (action: IUndoRedoItem) => void): IDisposable

Parameters

  • callback (action: IUndoRedoItem) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onBeforeUndo

Deprecated — use univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onBeforeUndo(callback: (action: IUndoRedoItem) => void): IDisposable

Parameters

  • callback (action: IUndoRedoItem) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onReady

Deprecated — use univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (&#123; stage &#125;) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onReady(callback: () => void): IDisposable

Parameters

  • callback () => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onRedo

Deprecated — use univerAPI.addEvent(univerAPI.Event.Redo, (event) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onRedo(callback: (action: IUndoRedoItem) => void): IDisposable

Parameters

  • callback (action: IUndoRedoItem) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onRendered

Deprecated — use univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (&#123; stage &#125;) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onRendered(callback: () => void): IDisposable

Parameters

  • callback () => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onStarting

Deprecated — use univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (&#123; stage &#125;) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onStarting(callback: () => void): IDisposable

Parameters

  • callback () => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onSteady

Deprecated — use univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (&#123; stage &#125;) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onSteady(callback: () => void): IDisposable

Parameters

  • callback () => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

onUndo

Deprecated — use univerAPI.addEvent(univerAPI.Event.Undo, (event) =&gt; &#123;&#125;) as instead

Signature

TypeScript
onUndo(callback: (action: IUndoRedoItem) => void): IDisposable

Parameters

  • callback (action: IUndoRedoItem) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/core

Miscellaneous

extend

Signature

TypeScript
static extend(source: any): void

Parameters

  • source anyNo description
Source: @univerjs/core

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.