Introduction
The Workbook class in Aspose.Cells FOSS enables developers to embed hyperlinks directly into Excel workbooks, supporting multiple link types including URLs, email addresses, external files, and internal worksheet references. This capability streamlines the creation of interactive spreadsheets that connect users to external resources or navigate complex internal structures with a single click.
Hyperlinks improve usability by allowing users to jump from data points to supporting documentation, contact information, or related sheets without leaving the spreadsheet environment. The library handles all common hyperlink scenarios natively, ensuring compatibility with Excel’s hyperlink behavior and formatting standards.
Key Highlights
- Supports URL hyperlinks (e.g., https://example.com) for web navigation
- Enables email hyperlinks (mailto:address) to open the default email client
- Allows linking to external files (e.g., file://C:/docs/report.xlsx) via absolute or relative paths
- Supports internal references (e.g., ‘Sheet2!A1’) to jump between worksheets within the same workbook
- Automatically applies Excel’s default hyperlink style (blue, underlined) to new links
- Integrates with the
Workbook’s protection model to preserve link integrity under sheet/workbook protection
Getting Started
To create a hyperlink in a cell, assign a formula using the =HYPERLINK() function. The library recognizes and preserves this formula as a functional hyperlink when the workbook is saved.
from aspose.cells_foss import Workbook
wb = Workbook()
ws = wb.worksheets[0]
# URL hyperlink
ws.cells["A1"].formula = '=HYPERLINK("https://example.com","Visit Example")'
# Email hyperlink
ws.cells["A2"].formula = '=HYPERLINK("mailto:user@example.com","Send Email")'
# Internal reference (same workbook, different sheet)
ws.cells["A3"].formula = '=HYPERLINK("#Sheet2!A1","Go to Sheet2")'
wb.save("hyperlinks.xlsx")
The =HYPERLINK() formula takes two arguments: the link target (URL, mailto:, or #SheetName!Cell) and the display text. Excel and LibreOffice render this as a clickable blue underlined link.