static private LoadXmlSafe ( |
||
xmlDoc | ||
stream | Stream | |
return | void |
/// <summary> /// Get the XmlDocument from an URI /// </summary> /// <param name="uri">The Uri to the part</param> /// <returns>The XmlDocument</returns> internal XmlDocument GetXmlFromUri(Uri uri) { XmlDocument xml = new XmlDocument(); Packaging.ZipPackagePart part = this.Package.GetPart(uri); XmlHelper.LoadXmlSafe(xml, part.GetStream()); return(xml); }
private Core.CellStore.ExcelValue GetCellStoreValue(int row, int col) { var v = _worksheet.GetCoreValueInner(row, col); if (_worksheet._flags.GetFlagValue(row, col, CellFlags.RichText)) { var xml = new XmlDocument(); XmlHelper.LoadXmlSafe(xml, "<d:si xmlns:d=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" >" + v._value.ToString() + "</d:si>", Encoding.UTF8); var rt = new ExcelRichTextCollection(_worksheet.NameSpaceManager, xml.SelectSingleNode("d:si", _worksheet.NameSpaceManager), this); v._value = rt.Text; } return(v); }
private void CreateXml(ExcelPackage pck) { var commentParts = Worksheet.Part.GetRelationshipsByType(ExcelPackage.schemaComment); bool isLoaded = false; CommentXml = new XmlDocument(); foreach (var commentPart in commentParts) { Uri = UriHelper.ResolvePartUri(commentPart.SourceUri, commentPart.TargetUri); Part = pck.Package.GetPart(Uri); XmlHelper.LoadXmlSafe(CommentXml, Part.GetStream()); RelId = commentPart.Id; isLoaded = true; } //Create a new document if (!isLoaded) { CommentXml.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"><authors /><commentList /></comments>"); Uri = null; } }
internal ExcelXmlSource(ZipPackagePart relPart, string relId) { if (string.IsNullOrEmpty(relId)) { Uri = XmlHelper.GetNewUri(relPart.Package, "/xl/slicers/slicer{0}.xml"); Part = relPart.Package.CreatePart(Uri, "application/vnd.ms-excel.slicer+xml", CompressionLevel.Default); Rel = relPart.CreateRelationship(UriHelper.GetRelativeUri(relPart.Uri, Uri), TargetMode.Internal, ExcelPackage.schemaRelationshipsSlicer); var xml = new XmlDocument(); XmlHelper.LoadXmlSafe(xml, "<slicers xmlns:xr10=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10\" xmlns:x=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" mc:Ignorable=\"x xr10\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" />", Encoding.UTF8); XmlDocument = xml; } else { Rel = relPart.GetRelationship(relId); Uri = UriHelper.ResolvePartUri(relPart.Uri, Rel.TargetUri); Part = relPart.Package.GetPart(Uri); var xml = new XmlDocument(); XmlHelper.LoadXmlSafe(xml, Part.GetStream()); XmlDocument = xml; } }