New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document. #249
Comments
Try taking it up with the OpenXML team first. I think this should be handled closer to the source. Tag the issue here, please. |
It's already been logged with them. Please see dotnet/Open-XML-SDK#38 |
Wow thanks for linking and all :). Great work! |
OpenXML v2.12.0+ introduced a workaround using |
I have limited capacity, but we welcome pull requests. |
I had an issue like this and it turns out upgrading OpenXML to 2.12.x and write the fix ourselves is very easy. It's just a couple of LOCs to rewrite the input stream. var settings = new OpenSettings
{
RelationshipErrorHandlerFactory = package =>
{
return new UriRelationShipErrorHandler();
},
};
var outputStream = new MemoryStream();
stream.CopyTo(outputStream);
stream.Position = 0;
using (var doc = SpreadsheetDocument.Open(outputStream, true, settings))
{
doc.Save();
}
outputStream.Position = 0;
// At this point, outputStream is ready for use by ClosedXML
using (var workbook = new XLWorkbook(outStream))
@igitur Could we just accept |
@hieuxlu , |
Hello @igitur, @hieuxlu, and @santerinogelainen, I am also facing the same exception though I am using version 2.13.0 of DocumentFormat.OpenXml Package. Can you please tell me the ETA when this issue will be resolved in the package? |
Hello @TrueBytes, Can you please help me with what you are passing and executing in the "UriRelationShipErrorHandler()" method. |
Hello @RajdeepRay0411 , following @hieuxlu tip you need to create a class that overrides Rewrite: using DocumentFormat.OpenXml.Packaging;
using System;
public class UriRelationshipErrorHandler : RelationshipErrorHandler
{
public override string Rewrite(Uri partUri, string id, string uri)
{
return "http://link-invalido";
}
} Example of use: var openSettings = new OpenSettings()
{
RelationshipErrorHandlerFactory = package =>
{
return new UriRelationshipErrorHandler();
}
};
using (var outputStream = File.Open(excelPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
{
using (var xls = SpreadsheetDocument.Open(outputStream, true, openSettings))
{
xls.Save();
}
var workbook = new XLWorkbook(outputStream);
.......
} Refereces: |
I get the Exception Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document.
at
I googled a little bit and apparently it is a common problem. You can't open a xlsx with a malformed Uri :(. Here is a Solution to the Problem http://ericwhite.com/blog/handling-invalid-hyperlinks-openxmlpackageexception-in-the-open-xml-sdk/ .
I looked in the sheet1.xml.rels and found the malformed Hyperlink, it has as Target:
" mailto:test.test@test-test.com;%2009.06.2015%20gibt%20ww%20Stahl ".
Maybe you can Implement the Solution from the Link or they already implemented a fitting overload as announced in the blog-post.
The text was updated successfully, but these errors were encountered: