4
Vote

UriFormatException on invalid hyperlinks

description

Hi!

I'm trying to read xlsx from Stream and UriFormatException is thrown in method LoadHyperLinks when the file contains either not valid hyperlinks or invalid port.

using (ExcelPackage package = new ExcelPackage(data))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
//process values in worksheet
}

I don't actually need LoadHyperLinks functionality, because I only have to read the records, process them and then reject the invalid ones, so I have commented this method out and it works now perfectly, but it would be nice if you can take a look at it.

I'm attaching my testing spreadsheet and also StackTrace content.

file attachments

comments

JanKallman wrote Jun 16, 2011 at 7:14 PM

This is actually the Packaging API that crashes when the URI is not valid.
To fix this I will need to read the .rel file manually. But since external URI only appear in the worksheet rel files it should be fairly simple to fix.

robsongdev wrote Dec 20, 2011 at 4:42 PM

Hi!

I´m having the same problem.
"I don't actually need LoadHyperLinks functionality, because I only have to read the records" [2]

I downloaded the source code and write a code that skips all invalid URI. But this breaks the compability with new upgrades. So, I'm searching for a better resolution for this issue. Because if the worksheet have only one broken hyperlink, I can't read all data.

jtrout wrote Apr 24, 2012 at 5:36 PM

This is biting me at the moment too, because the client has attempted to upload an Excel file where the e-mail addresses have all been converted to mailto: links. There has got to be a better way to turn off the hyperlink parsing.