add method
Hyperlink
add(
- Range range,
- HyperlinkType linkType,
- String address, [
- String? screenTip,
- 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.isHyperlinkStyle = 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;
}