Import and Export Service
Import Process
- Upload the file to object storage and obtain the
fileID
return value. - Call the import interface with the
fileID
parameter, setting the export typeoutputType
(1 for importing as a unit document, 2 for obtaining JSON data), and get thetaskID
return value. - Poll to get the conversion result, handling based on the
status
return value:pending
: Continue polling.done
: Conversion successful, obtainingimport.jsonID
orimport.unitID
return value.failed
: Conversion failed, retrieve error information fromerror.message
.
- If you want to obtain JSON data instead of a unit document, use
import.jsonID
to call the file retrieval interface to download the conversion result. Note that after obtaining the JSON data, you still need to convert it before it can be used in Univer.
Export Process
- Call the export interface with the
unitID
parameter to obtain thetaskID
return value. - Poll to get the conversion result, handling based on the
status
return value:pending
: Continue polling.done
: Conversion successful, obtainingexport.fileID
return value.failed
: Conversion failed, retrieve error information fromerror.message
.
- Use
export.fileID
to call the file retrieval interface to download the conversion result.
API
See the Univer Server API Definition
Example of import:https://github.com/dream-num/usip-example/tree/main/import