FRangeSheetDrawingUI

GitHubEdit on GitHub
packages@univerjs/sheets-drawing-ui

APIs

insertCellImageAsync

Inserts an image into the current cell.

Signature

insertCellImageAsync(file: File | string): Promise<boolean>

Parameters

  • file (File | string) — File or URL string

Returns

  • (Promise<boolean>) — True if the image is inserted successfully, otherwise false

Examples

const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()

// Insert an image into the cell A10
const fRange = fWorksheet.getRange('A10')
const result = await fRange.insertCellImageAsync('https://avatars.githubusercontent.com/u/61444807?s=48&v=4')
console.log(result)

saveCellImagesAsync

Save all cell images in this range to the file system. This method will open a directory picker dialog and save all images to the selected directory.

Signature

saveCellImagesAsync(options?: ISaveCellImagesOptions): Promise<boolean>

Parameters

  • options (ISaveCellImagesOptions) — Options for saving images

Returns

  • (Promise<boolean>) — True if images are saved successfully, otherwise false

Examples

const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getActiveSheet()

// Save all cell images in range A1:D10
const fRange = fWorksheet.getRange('A1:D10')

// Save with default options (using cell address as file name)
await fRange.saveCellImagesAsync()

// Save with custom options
await fRange.saveCellImagesAsync({
  useCellAddress: true,
  useColumnIndex: 0, // Use values from column A for file names
})