Excel hyperlinks break when copying rows

Hi support,

I’m running into an issue when copying rows that contain Excel HYPERLINK formulas. Almost all hyperlinks in copied rows don’t work when saving to file formats other than Excel.

See the test case below for an example:

Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];

sheet.Cells["A1"].Formula = "=HYPERLINK(\"https://aspose.com\", \"Aspose\")";
sheet.Cells.CopyRows(sheet.Cells, 0, 1, 1);
sheet.CalculateFormula(new CalculationOptions(), true);

book.Save(@"c:\data\hyperlink_test.xlsx"); //These hyperlinks work
book.Save(@"c:\data\hyperlink_test.pdf", SaveFormat.Pdf); //These hyperlinks don't all work
book.Save(@"c:\data\hyperlink_test.html", SaveFormat.Html); //These hyperlinks don't all work

Thanks,
Justin

@jziske

Cause

The issue you’re experiencing with hyperlinks breaking when copying rows in Excel is likely due to how the hyperlinks are handled during the conversion process to formats like PDF and HTML. When you copy rows, the references in the hyperlinks may not be preserved correctly, leading to them not functioning as expected in the exported formats.

Solution

To ensure that hyperlinks remain functional after copying rows and exporting to different formats, you can implement a custom approach to handle the hyperlinks explicitly. This involves re-establishing the hyperlinks after copying the rows.

Code

Here’s a modified version of your code that copies the rows and re-establishes the hyperlinks:

Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];

// Create a hyperlink in the first cell
sheet.Cells["A1"].Formula = "=HYPERLINK(\"https://aspose.com\", \"Aspose\")";

// Copy the first row to the second row
sheet.Cells.CopyRows(sheet.Cells, 0, 1, 1);

// Re-establish the hyperlink in the copied row
string hyperlinkAddress = "https://aspose.com";
string hyperlinkText = "Aspose";
sheet.Hyperlinks.Add("A2", 1, 0, 1, 1, hyperlinkAddress, hyperlinkText);

// Save to different formats
book.Save(@"c:\data\hyperlink_test.xlsx"); // These hyperlinks work
book.Save(@"c:\data\hyperlink_test.pdf", SaveFormat.Pdf); // Hyperlinks should work now
book.Save(@"c:\data\hyperlink_test.html", SaveFormat.Html); // Hyperlinks should work now

In this code, after copying the row, we manually add the hyperlink back to the new location.

Next Steps

  1. Test the modified code to ensure that hyperlinks work in both PDF and HTML formats.
  2. If you have multiple hyperlinks, consider creating a loop to handle them dynamically based on your requirements.
  3. Review the Aspose.Cells documentation for any additional options related to hyperlink management during export.

Please implement these changes and let me know if you encounter any further issues!

@jziske,

Thanks for the details.

I was able to reproduce the issue as you mentioned by using your sample code snippet. I found when copying rows that contain Excel HYPERLINK formulas, almost all hyperlinks in copied rows don’t work when saving to file formats other than Excel.

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-58761

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@amjad.sahi ,

Thank you for your quick response. If a hotfix is available, it would help us. Otherwise, we will downgrade until the fix is released. Would it be better to ask this in the Paid Support channel?

Thank you,
-Andy

@weissa
Since your issue was logged just a few hours ago, please allow us some time to evaluate and analyze it in detail. If it is not complex, we should be able to fix it soon, and the fix may be included in our upcoming release (Aspose.Cells v25.8 - planned for publication in the second week of August next month). If the issue is complex, it may take a few more weeks or even a month to resolve.

Additionally, sorry, we are unable to provide you with a fixed version. After the issue is fixed, we will provide a fixed file for your reference. According to company regulations, only those with priority services will be provided with fix versions, so if you want to obtain fix versions faster, you need to purchase priority support. If there is no priority service, fix will also be released in the next release version.

You may check our paid support option where issues are prioritized and posses highest priority if your issue is a real blocker.

@weissa,

We are pleased to inform you that your issue (Ticket ID: “CELLSNET-58761”) has been resolved. The fix/enhancement will be incorporated into the upcoming release of Aspose.Cells (v25.8), which is scheduled for the first half of August 2025. You will be notified when the new version is published.

@amjad.sahi ,

Thank you for letting us know, we’ll keep an eye out for the new version in August.

-Andy

@weissa
You are welcome!
You will be notified when the new version is published in the next month.