We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding Hyperlink on Cell with Large amount of Characters Issue

When trying to open a xlsx file after creating it with a large amount of text and a hyperlink on that cell, I get a message from Excel, “We found a problem with some content in ‘output.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workfbook, click Yes.”

After some digging into the xlsx metadata, I found that the created file with the code below inserts the cell text into the display attribute of the hyperlink node in the xml. When creating a hyperlink normally in an excel document it doesn’t use the display attribute, and just leaves it empty, so there is no issue.

Example of Aspose created hyperlink portion: <hyperlink ref=“A1” r:id=“rId1” display="Bacon …

I found that the approximate limit is 2075 characters.

Is there any workaround where I can get the Cell.Value set and apply a hyperlink without this problem. Thanks.

Code to reproduce:

private void CreateWorkbookWithHyperlink()

{

Workbook book = new Workbook();

Cell cell = book.Worksheets[0].Cells[“A1”];

string html = //Insert string text over 3000 characters here.

//cell.HtmlString = html; //Setting either the HtmlString or the Value both produce bad data.

cell.Value = html;

book.Worksheets[0].Hyperlinks.Add(0, 0, 1, 1, “http://www.aspose.com”);

book.Save(@“c:\output.xlsx”, SaveFormat.Xlsx);

}

Hi,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue by executing the following sample code using the latest version: Aspose.Cells
for .NET v8.5.1.5
. We found that adding 2084 characters in hyperlink does not corrupt output excel file but adding more than 2084 characters corrupts the output excel file.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43830 - Adding more than 2084 characters in hyperlink corrupts the output xlsx file

I have attached the output excel file generated with the following code for a reference. The output excel file is corrupt and does not open in Microsoft Excel.

C#

Workbook book = new Workbook();

Cell cell = book.Worksheets[0].Cells[“A1”];

string html = “”;

//Aspose.Cells supports upto 2084 characters

//3000 characters will corrupt the xlsx file

for (int i = 0; i < 3000; i++)

{

html = html + “a”;

}

cell.Value = html;

book.Worksheets[0].Hyperlinks.Add(0, 0, 1, 1, “http://www.aspose.com”);

book.Save(@“output.xlsx”, SaveFormat.Xlsx);

Hi,

Thanks for using Aspose.Cells.

We have evaluated this issue further and found that it is the limitation of MS Excel that the address and display must be less than 2084 characters.

We will not export “display” as MS Excel if it’s out of the limitation.

So if I understand correctly, when the Cell Text is greater than the display limitation, it will still be hyperlinked but the display will not be used and the cell.value will?

Hi,

Thanks for your posting and using Aspose.Cells.

It seems we will throw exception on creating such a hyperlink. Anyway, I have logged your comment in our database against this issue for product team. We will look into it and provide you a clarification in this regard. Once there is some update for you, we will let you know asap.

Hi,

Thanks for using Aspose.Cells.

ZDougherty:
So if I understand correctly, when the Cell Text is greater than the display limitation, it will still be hyperlinked but the display will not be used and the cell.value will?


Yes, your understanding is correct.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.5.2.1 and let us know your feedback.

It is working now. Thanks.

Hi,

It is good to know that you are up & running again. Please feel free to contact us back in case you need our further assistance with Aspose APIs.

The issues you have found earlier (filed as CELLSNET-43830) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.