add method

Hyperlink add(
  1. Range range,
  2. HyperlinkType linkType,
  3. String address, [
  4. String? screenTip,
  5. String? textToDisplay,
])

Add hyperlink to the hyperlink collection.

final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final Range range = sheet.getRangeByName('A1');

// Add hyperlink to sheet.
final Hyperlink link = sheet.hyperlinks
    .add(range, HyperlinkType.url, 'http://www.syncfusion.com');
link.screenTip = 'Click Here to know about Syncfusion';
link.textToDisplay = 'Syncfusion';

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

Implementation

Hyperlink add(Range range, HyperlinkType linkType, String address,
    [String? screenTip, String? textToDisplay]) {
  final Hyperlink hyperlink = Hyperlink(_worksheet);
  hyperlink._bHyperlinkStyle = range.builtInStyle = BuiltInStyles.hyperlink;
  hyperlink._row = range.row;
  hyperlink._column = range.column;
  hyperlink.type = linkType;
  hyperlink.address = address;
  if (screenTip != null) {
    hyperlink.screenTip = screenTip;
  }
  if (textToDisplay != null) {
    hyperlink.textToDisplay = textToDisplay;
  }
  hyperlink._attachedType = ExcelHyperlinkAttachedType.range;
  addHyperlink(hyperlink);
  return hyperlink;
}