Quantcast
Viewing all articles
Browse latest Browse all 1621

Created Unassigned: Import xlsx file [12207]

Hello All.

Import xlsx files that contains incorrect links return "Invalid URI" exception when try to create woorkbook.
using (Stream file = stream)
{
XSSFWorkbook xssfworkbook = new XSSFWorkbook(file);
}
It is not good that you can't create woorkbook cause of incorrect hyperlink in excel file and need to waste a lot of time to find out what is wrong in document. In my project I don't use links from excel.

So it would be great if you can fix this (do not add incorrect hyperlinks but continue to load document)

Changed method XSSFSheet.cs

private void InitHyperlinks()
{
hyperlinks = new List<XSSFHyperlink>();

if (!worksheet.IsSetHyperlinks()) return;

try
{
PackageRelationshipCollection hyperRels =
GetPackagePart().GetRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.Relation);

// Turn each one into a XSSFHyperlink
foreach (NPOI.OpenXmlFormats.Spreadsheet.CT_Hyperlink hyperlink in worksheet.hyperlinks.hyperlink)
{
PackageRelationship hyperRel = null;
if (hyperlink.id != null)
{
hyperRel = hyperRels.GetRelationshipByID(hyperlink.id);
}

try
{
hyperlinks.Add(new XSSFHyperlink(hyperlink, hyperRel));
}
catch { }
}
}
catch (InvalidFormatException e)
{
throw new POIXMLException(e);
}
}

Viewing all articles
Browse latest Browse all 1621

Trending Articles