11using NanoXLSX.Interfaces;
12using NanoXLSX.Interfaces.Reader;
13using NanoXLSX.Registry;
14using NanoXLSX.Registry.Attributes;
16using IOException =
NanoXLSX.Exceptions.IOException;
24 [NanoXlsxPlugIn(PlugInUUID = PlugInUUID.RelationshipReader)]
27 private MemoryStream stream;
63 public void Init(MemoryStream stream,
Workbook workbook, IOptions readerOptions, Action<MemoryStream, Workbook, string, IOptions, int?> inlinePluginHandler)
66 this.Workbook = workbook;
67 this.Options = readerOptions;
68 this.InlinePluginHandler = inlinePluginHandler;
77 if (stream ==
null)
return;
87 using (XmlReader reader = XmlReader.Create(stream,
new XmlReaderSettings() { XmlResolver =
null }))
90 XmlNodeList relationships = xr.GetElementsByTagName(
"Relationship");
91 foreach (XmlNode relationship
in relationships)
96 if (ParserUtils.StartsWith(target,
"/"))
98 target = target.TrimStart(
'/');
100 if (ParserUtils.NotStartsWith(target,
"xl/"))
102 target =
"xl/" + target;
110 Workbook.AuxiliaryData.SetData(PlugInUUID.RelationshipReader, PlugInUUID.RelationshipEntity,
id, rel);
118 throw new IOException(
"The XML entry could not be read from the input stream. Please see the inner exception:", ex);
Static class with common util methods, used during reading XLSX files.
static string GetAttribute(XmlNode node, string targetName, string fallbackValue=null)
Gets the XML attribute of the passed XML node by its name.
RelationshipReader()
Default constructor - Must be defined for instantiation of the plug-ins.
void Execute()
Method to execute the main logic of the plug-in (interface implementation).
IOptions Options
Reader options.
void Init(MemoryStream stream, Workbook workbook, IOptions readerOptions, Action< MemoryStream, Workbook, string, IOptions, int?> inlinePluginHandler)
Initialization method (interface implementation).
Workbook Workbook
Workbook reference where read data is stored (should not be null).
Action< MemoryStream, Workbook, string, IOptions, int?> InlinePluginHandler
Reference to the ReaderPlugInHandler, to be used for post operations in the Execute method.
Class to represent a workbook relation.
Exceptions.IOException IOException