Interactive Features in Excel with ExpertXls Spreadsheet Library for .NET |
A worksheet can contain hyperlinks and cell comments. A hyperlink (ExcelHyperlink) opens a web page, starts an e-mail message, opens a file, or goes to a range of the workbook. Add hyperlinks to the Hyperlinks collection with AddHyperlink(ExcelHyperlinkType, ExcelRange, String).
A hyperlink to a web page and a hyperlink to an e-mail address:
ExcelHyperlink webLink = worksheet.Hyperlinks.AddHyperlink(ExcelHyperlinkType.Url, worksheet["A1"], "https://www.html-to-pdf.info/excel-library.aspx"); webLink.Text = "Visit the product website"; webLink.ToolTip = "Opens the ExpertXls website"; ExcelHyperlink mailLink = worksheet.Hyperlinks.AddHyperlink(ExcelHyperlinkType.Url, worksheet["A2"], "mailto:customer@example.com"); mailLink.Text = "customer@example.com";
A hyperlink to a range of another worksheet targets a named range:
ExcelWorksheet chartWorksheet = workbook.Worksheets.AddWorksheet("Simple Chart"); workbook.NamedRanges.AddNamedRange(chartWorksheet["A1"], "ChartWorksheet"); ExcelHyperlink sheetLink = worksheet.Hyperlinks.AddHyperlink(ExcelHyperlinkType.Range, worksheet["A4"], "ChartWorksheet"); sheetLink.Text = "Go to the chart worksheet";
AddComment(String) adds a comment to a cell. Excel shows the comment when the mouse is over the cell.