Skip to Content
ClassesFOverGridImage

Class: FOverGridImage

Extends

  • FBase

Methods

getId()

getId(): string

Returns

string


getType()

getType(): DrawingTypeEnum

Returns

DrawingTypeEnum


remove()

remove(): boolean

Remove the image from the sheet

Returns

boolean

success or not

Example

// remove the image from the sheet const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Delete state is ', image?.remove());

setBack()

setBack(): boolean

Move the image layer to the back

Returns

boolean

success or not

Example

// move the image to the back const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Move back state is ', image.setBack());

setBackward()

setBackward(): boolean

Move the image layer backward by one level

Returns

boolean

success or not

Example

// move the image backward const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Move backward state is ', image.setBackward());

setCrop()

setCrop( top?, left?, bottom?, right?): boolean

Set the cropping region of the image by defining the top, bottom, left, and right edges, thereby displaying the specific part of the image you want.

Parameters

ParameterTypeDescription
top?numberThe number of pixels to crop from the top of the image.
left?numberThe number of pixels to crop from the left side of the image.
bottom?numberThe number of pixels to crop from the bottom of the image.
right?numberThe number of pixels to crop from the right side of the image.

Returns

boolean

success or not

Example

// set the crop of the image const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Set crop state is ', image.setCrop(10, 10, 10, 10));

setForward()

setForward(): boolean

Move the image layer forward by one level

Returns

boolean

success or not

Example

// move the image forward const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Move forward state is ', image.setForward());

setFront()

setFront(): boolean

Move the image layer to the front

Returns

boolean

success or not

Example

// move the image to the front const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Move front state is ', image.setFront());

setPositionAsync()

Call Signature

setPositionAsync(row, column): Promise<boolean>

Set the position of the image

Parameters
ParameterTypeDescription
rownumberThe sheet start row of the image
columnnumberThe sheet start column of the image
Returns

Promise<boolean>

success or not

Example
// set the position of the image const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Set position state is ', image.setPosition(5, 5));

Call Signature

setPositionAsync( row, column, rowOffset?, columnOffset?): Promise<boolean>
Parameters
ParameterTypeDescription
rownumberThe sheet start row of the image
columnnumberThe sheet start column of the image
rowOffset?numberThe offset of the start row
columnOffset?numberThe offset of the start column
Returns

Promise<boolean>

success or not

Example
// set the position of the image const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Set position state is ', image.setPosition(5, 5, 10, 10));

setRotate()

setRotate(angle): boolean

Set the rotation angle of the image

Parameters

ParameterTypeDescription
anglenumberDegree of rotation of the image, for example, 90, 180, 270, etc.

Returns

boolean

success or not

Example

// set the rotation angle of the image const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Set rotate state is ', image.setRotate(90));

setSizeAsync()

setSizeAsync(width, height): Promise<boolean>

Set the size of the image

Parameters

ParameterTypeDescription
widthnumberThe width of the image
heightnumberThe height of the image

Returns

Promise<boolean>

success or not

Example

// set the size of the image const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Set size state is ', image.setSize(50, 120)); *** ### setSource() #### Call Signature ```ts setSource(source): boolean

Set the source of the image

Parameters
ParameterTypeDescription
sourcestringThe source of the image
Returns

boolean

success or not

Example
// set the source of the image const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; console.log('Set source state is ', image.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4')); #### Call Signature ```ts setSource(source, sourceType?): boolean

Set the source of the image, change image display.

Parameters
ParameterTypeDescription
sourcestringThe source of the image
sourceType?ImageSourceTypeThe source type of the image, ImageSourceType
Returns

boolean

success or not


toBuilder()

toBuilder(): FOverGridImageBuilder

Convert the image to a FOverGridImageBuilder

Returns

FOverGridImageBuilder

The builder FOverGridImageBuilder

Example

// convert the image to a builder const activeSpreadsheet = univerAPI.getActiveWorkbook(); const activeSheet = activeSpreadsheet.getActiveSheet(); const image = activeSheet.getImages()[0]; const builder = image.toBuilder(); const param = await builder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).buildAsync(); activeSheet.updateImages([param]);