FUniverExchangeClientMixin
| packages | @univerjs-pro/exchange-client |
|---|
APIs
exportDOCXBySnapshotAsync
Export DOCX file by snapshot
Signature
exportDOCXBySnapshotAsync(snapshot: IDocumentData): Promise<File | undefined>Parameters
snapshot(IDocumentData) — Document data
Returns
- (
Promise<File | undefined>) — DOCX file
Examples
const snapshot = univerAPI.getActiveDocument().save()
const file = await univerAPI.exportDOCXBySnapshotAsync(snapshot)
downloadFile(file, 'univer', 'docx')exportDOCXByUnitIdAsync
Export DOCX file by unit id
Signature
exportDOCXByUnitIdAsync(unitId: string): Promise<File | undefined>Parameters
unitId(string) — Unit id
Returns
- (
Promise<File | undefined>) — XLSX file
Examples
const unitId = univerAPI.getActiveWorkbook().getId()
const file = await univerAPI.exportDOCXByUnitIdAsync(unitId)
downloadFile(file, 'univer', 'docx')exportXLSXBySnapshot
Export XLSX file by workbook data
Deprecated
Please use exportXLSXBySnapshotAsync instead.
Signature
exportXLSXBySnapshot(snapshot: IWorkbookData): Promise<File | undefined>Parameters
snapshot(IWorkbookData)
Returns
- (
Promise<File | undefined>) — XLSX file
exportXLSXBySnapshotAsync
Export XLSX file by workbook data
Signature
exportXLSXBySnapshotAsync(snapshot: IWorkbookData): Promise<File | undefined>Parameters
snapshot(IWorkbookData)options
Returns
- (
Promise<File | undefined>) — A promise that resolves to the XLSX file
Examples
import { downloadFile } from '@univerjs-pro/exchange-client'
const fWorkbook = univerAPI.getActiveWorkbook()
const snapshot = fWorkbook.save()
const file = await univerAPI.exportXLSXBySnapshotAsync(snapshot)
// or with server-side calculation enabled
// const file = await univerAPI.exportXLSXBySnapshotAsync(snapshot, { enableServerCalculation: true });
// Download the file
downloadFile(file, 'univer', 'xlsx')exportXLSXByUnitId
Export XLSX file by unit id
Deprecated
Please use exportXLSXByUnitIdAsync instead.
Signature
exportXLSXByUnitId(unitId: string): Promise<File | undefined>Parameters
unitId(string)
Returns
- (
Promise<File | undefined>) — XLSX file
exportXLSXByUnitIdAsync
Export XLSX file by unit id
Signature
exportXLSXByUnitIdAsync(unitId: string): Promise<File | undefined>Parameters
unitId(string)options
Returns
- (
Promise<File | undefined>) — A promise that resolves to the XLSX file
Examples
import { downloadFile } from '@univerjs-pro/exchange-client'
const fWorkbook = univerAPI.getActiveWorkbook()
const unitId = fWorkbook.getId()
const file = await univerAPI.exportXLSXByUnitIdAsync(unitId)
// or with server-side calculation enabled
// const file = await univerAPI.exportXLSXByUnitIdAsync(unitId, { enableServerCalculation: true });
// Download the file
downloadFile(file, 'univer', 'xlsx')importDOCXToSnapshot
Import DOCX file to document data
Deprecated
Please use importDOCXToSnapshotAsync instead.
Signature
importDOCXToSnapshot(file: string | File): Promise<IDocumentData | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<IDocumentData | undefined>) — Document data
importDOCXToSnapshotAsync
Import DOCX file to document data
Signature
importDOCXToSnapshotAsync(file: string | File): Promise<IDocumentData | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<IDocumentData | undefined>) — A promise that resolves to the document data
Examples
// Accepts a File object
const snapshot = await univerAPI.importDOCXToSnapshotAsync(file)
// Or accepts a URL to a remote file
// const snapshot = await univerAPI.importDOCXToSnapshotAsync('https://example.com/filename.docx');
console.log('Snapshot created:', snapshot)importDOCXToUnitId
Import DOCX file to unit id
Deprecated
Please use importDOCXToUnitIdAsync instead.
Signature
importDOCXToUnitId(file: string | File): Promise<string | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<string | undefined>) — Unit id
importDOCXToUnitIdAsync
Import DOCX file to unit id
Signature
importDOCXToUnitIdAsync(file: string | File): Promise<string | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<string | undefined>) — A promise that resolves to the unit id
Examples
// Accepts a File object
const unitId = await univerAPI.importDOCXToUnitIdAsync(file)
// Or accepts a URL to a remote file
// const unitId = await univerAPI.importDOCXToUnitIdAsync('https://example.com/filename.docx');
const url = new URL(window.location.href)
const unit = url.searchParams.get('unit')
url.searchParams.set('unit', unitId)
url.searchParams.set('type', '1') // The meaning of "1" is String(UniverInstanceType.UNIVER_DOC)
// Open the unit in the new window
window.open(url.toString(), '_blank')importXLSXToSnapshot
Import XLSX file to workbook data
Deprecated
Please use importXLSXToSnapshotAsync instead.
Signature
importXLSXToSnapshot(file: string | File): Promise<IWorkbookData | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<IWorkbookData | undefined>) — Workbook data
importXLSXToSnapshotAsync
Import XLSX file to workbook data
Signature
importXLSXToSnapshotAsync(file: string | File): Promise<IWorkbookData | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<IWorkbookData | undefined>) — A promise that resolves to the workbook data
Examples
// Accepts a File object
const snapshot = await univerAPI.importXLSXToSnapshotAsync(file)
// Or accepts a URL to a remote file
// const snapshot = await univerAPI.importXLSXToSnapshotAsync('https://example.com/filename.xlsx');
console.log('Snapshot created:', snapshot) // see more: https://docs.univer.ai/en-US/guides/sheets/getting-started/workbook-data
// Create a new workbook with the snapshot
univerAPI.createWorkbook(snapshot)importXLSXToUnitId
Import XLSX file to unit id
Deprecated
Please use importXLSXToUnitIdAsync instead.
Signature
importXLSXToUnitId(file: string | File): Promise<string | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<string | undefined>) — Unit id
importXLSXToUnitIdAsync
Import XLSX file to unit id
Signature
importXLSXToUnitIdAsync(file: string | File): Promise<string | undefined>Parameters
file(string | File) — File path or file object
Returns
- (
Promise<string | undefined>) — A promise that resolves to the unit id
Examples
// Accepts a File object
const unitId = await univerAPI.importXLSXToUnitIdAsync(file)
// Or accepts a URL to a remote file
// const unitId = await univerAPI.importXLSXToUnitIdAsync('https://example.com/filename.xlsx');
// Utilize automatic data loading in conjunction with collaborative editing. https://docs.univer.ai/en-US/guides/sheets/features/collaboration#loading-collaborative-documents
const url = new URL(window.location.href)
const unit = url.searchParams.get('unit')
url.searchParams.set('unit', unitId)
url.searchParams.set('type', '2') // The meaning of "2" is String(UniverInstanceType.UNIVER_SHEET)
console.log('Unit URL:', url.toString())
// Open the unit in the new window
window.open(url.toString(), '_blank')