Class: FOverGridImage
Extends
FBase
Methods
getId()
getId(): string
Returns
string
getType()
getType(): DrawingTypeEnum
Returns
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
Parameter | Type | Description |
---|---|---|
top ? | number | The number of pixels to crop from the top of the image. |
left ? | number | The number of pixels to crop from the left side of the image. |
bottom ? | number | The number of pixels to crop from the bottom of the image. |
right ? | number | The 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
Parameter | Type | Description |
---|---|---|
row | number | The sheet start row of the image |
column | number | The 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
Parameter | Type | Description |
---|---|---|
row | number | The sheet start row of the image |
column | number | The sheet start column of the image |
rowOffset ? | number | The offset of the start row |
columnOffset ? | number | The 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
Parameter | Type | Description |
---|---|---|
angle | number | Degree 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
Parameter | Type | Description |
---|---|---|
width | number | The width of the image |
height | number | The 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
Parameter | Type | Description |
---|---|---|
source | string | The 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
Parameter | Type | Description |
---|---|---|
source | string | The source of the image |
sourceType ? | ImageSourceType | The source type of the image, ImageSourceType |
Returns
boolean
success or not
toBuilder()
toBuilder(): FOverGridImageBuilder
Convert the image to a FOverGridImageBuilder
Returns
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]);