When trying to load a excel file, containing an invalid hyperlink, the following exception is thrown:
Unhandled Exception: System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateHostStringHelper(String str, UInt16 idx, UInt16 end, Flags& flags, String& scopeId)
at System.Uri.CreateHostString()
at System.Uri.EnsureHostString(Boolean allowDnsOptimization)
at System.Uri.GetComponentsHelper(UriComponents uriComponents, UriFormat uriFormat)
at System.Uri.GetComponents(UriComponents components, UriFormat format)
at System.Uri.get_AbsoluteUri()
at OfficeOpenXml.ExcelWorksheet.LoadHyperLinks(XmlTextReader xr) in EPPlus\ExcelWorksheet.cs:line 800
at OfficeOpenXml.ExcelWorksheet.CreateXml() in EPPlus\ExcelWorksheet.cs:line 553
at OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int 32 positionID, eWorkSheetHidden hide) in EPPlus\ExcelWorksheet.cs:line 184
at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManagernsm, XmlNode topNode) in EPPlus\ExcelWorksheets.cs:line 83
at OfficeOpenXml.ExcelWorkbook.get_Worksheets() in EPPlus\ExcelWorkbook.cs:line 254
Excel doesn't have any problem loading the same excel file.
I am using EPPlus Source: commit c578b32e89e.
Example program:
```
using System;
using System.IO;
using OfficeOpenXml;
class Program
{
static void Main(string[] args)
{
var file = new FileInfo("Book-hyperlink-error.xlsx");
var excelPackage = new ExcelPackage(file);
var workbook = excelPackage.Workbook; // UriFormatException thrown here
// Just to make sure the previous line is processed
Console.WriteLine("Worksheet count: " + workbook.Worksheets.Count);
}
}
```
Excel file with an invalid hyperlink is attached.
Unhandled Exception: System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateHostStringHelper(String str, UInt16 idx, UInt16 end, Flags& flags, String& scopeId)
at System.Uri.CreateHostString()
at System.Uri.EnsureHostString(Boolean allowDnsOptimization)
at System.Uri.GetComponentsHelper(UriComponents uriComponents, UriFormat uriFormat)
at System.Uri.GetComponents(UriComponents components, UriFormat format)
at System.Uri.get_AbsoluteUri()
at OfficeOpenXml.ExcelWorksheet.LoadHyperLinks(XmlTextReader xr) in EPPlus\ExcelWorksheet.cs:line 800
at OfficeOpenXml.ExcelWorksheet.CreateXml() in EPPlus\ExcelWorksheet.cs:line 553
at OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int 32 positionID, eWorkSheetHidden hide) in EPPlus\ExcelWorksheet.cs:line 184
at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManagernsm, XmlNode topNode) in EPPlus\ExcelWorksheets.cs:line 83
at OfficeOpenXml.ExcelWorkbook.get_Worksheets() in EPPlus\ExcelWorkbook.cs:line 254
Excel doesn't have any problem loading the same excel file.
I am using EPPlus Source: commit c578b32e89e.
Example program:
```
using System;
using System.IO;
using OfficeOpenXml;
class Program
{
static void Main(string[] args)
{
var file = new FileInfo("Book-hyperlink-error.xlsx");
var excelPackage = new ExcelPackage(file);
var workbook = excelPackage.Workbook; // UriFormatException thrown here
// Just to make sure the previous line is processed
Console.WriteLine("Worksheet count: " + workbook.Worksheets.Count);
}
}
```
Excel file with an invalid hyperlink is attached.