addImage method

Hyperlink addImage(
  1. Picture picture,
  2. HyperlinkType linkType,
  3. String address, [
  4. String? screenTip,
])

Add Image hyperlink to the hyperlink collection.

final Workbook workbook = Workbook(1);
final Worksheet sheet = workbook.worksheets[0];
// Add picture to sheet.
final Picture picture1 = sheet.pictures.addBase64(1, 1, image14png);

// Add image hyperlink to sheet.
Hyperlink link = sheet.hyperlinks.addImage(picture1, HyperlinkType.url,
    'mailto:Username@syncfusion.com');
link.screenTip = 'Mail to User';

//Save and dispose.
List<int> bytes = workbook.saveAsStream();
File('HyperlinksImage.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

Hyperlink addImage(Picture picture, HyperlinkType linkType, String address,
    [String? screenTip]) {
  final Hyperlink hyperlink = Hyperlink(_worksheet);
  hyperlink.type = linkType;
  hyperlink.address = address;
  if (screenTip != null) {
    hyperlink.screenTip = screenTip;
  }
  hyperlink.attachedType = ExcelHyperlinkAttachedType.shape;
  picture.isHyperlink = true;
  picture.hyperlink = hyperlink;
  addHyperlink(hyperlink);
  return hyperlink;
}