Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SetHyperlink Method to Support Adding Hyperlinks to Cells #26

Merged
merged 3 commits into from
Dec 30, 2024

Conversation

fahadadeel
Copy link
Collaborator

@fahadadeel fahadadeel commented Dec 30, 2024

Summary

This pull request introduces a new feature to the Cell class: the SetHyperlink method. This method allows users to programmatically add hyperlinks to cells with optional tooltips.

Key Changes

  • Added the SetHyperlink method in the Cell class:
    • Supports adding a hyperlink to a cell in A1 notation.
    • Includes an optional tooltip that appears when hovering over the hyperlink.
  • Implemented a helper method GetWorksheetPart to locate the WorksheetPart containing the current cell.
  • Integrated OpenXML SDK features:
    • Utilized Hyperlink and Hyperlinks elements for hyperlink management.
    • Used OpenXML relationship handling to associate hyperlinks with worksheets.
  • Included comprehensive XML documentation for both methods.

Example Usage

using (Workbook wb = new Workbook("path/to/your/file.xlsx"))
{
    Worksheet sheet = wb.Worksheets[0];
    Cell cell = sheet.Cells["B10"];
    cell.PutValue("Click Here");
    cell.SetHyperlink("https://example.com", "Visit Example Website");
    wb.Save("path/to/your/file.xlsx");
}

Fixes #25 
Closes #25 

@fahadadeel fahadadeel merged commit 82364f4 into fileformat-cells:main Dec 30, 2024
1 check passed
@fahadadeel fahadadeel linked an issue Dec 30, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to add a hyperlink in a cell using FileFormat.Cells
1 participant