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);
}