Skip to content

Commit 2015bb7

Browse files
committed
Squashed commit of the following:
commit 815eb29 Merge: efb45c5 ff7fa87 Author: Tony Qu <[email protected]> Date: Fri Apr 26 22:37:31 2024 +0800 Merge pull request nissl-lab#1316 from antony-liu/poi/v3.16-patch3 Some patches ported from poi commit efb45c5 Merge: 5cb561d b48fe66 Author: Tony Qu <[email protected]> Date: Fri Apr 26 21:51:49 2024 +0800 Merge pull request nissl-lab#1284 from superrnovae/bmp_pictures Opening existing workbook with pictures, adding new ones and saving it should not throw an exception commit ff7fa87 Merge: cc1de9a 5cb561d Author: Antony Liu <[email protected]> Date: Fri Apr 26 20:59:25 2024 +0800 Merge branch 'master' into poi/v3.16-patch3 commit 5cb561d Merge: e82fa27 c0378c6 Author: Tony Qu <[email protected]> Date: Thu Apr 25 02:05:43 2024 +0800 Merge pull request nissl-lab#1303 from Bykiev/FixCreateCellComment XLS - Fix adding cell comment commit e82fa27 Merge: 83106c2 989cb6b Author: Tony Qu <[email protected]> Date: Wed Apr 24 19:43:02 2024 +0800 Merge branch 'master' of https://github.com/nissl-lab/npoi commit 83106c2 Author: Tony Qu <[email protected]> Date: Wed Apr 24 19:42:35 2024 +0800 fix nissl-lab#1315 - rollback the change of dt2D and dtr property commit 989cb6b Merge: 7fd6e4c 9fe58ed Author: Tony Qu <[email protected]> Date: Wed Apr 24 04:19:14 2024 +0800 Merge pull request nissl-lab#1281 from superrnovae/xssf_formula_results_format [Bug 67785] Make XSSFExcelExtractor output more like that from XSSFEventBasedExcelExtractor commit 7fd6e4c Merge: 976c1f5 7892c92 Author: Tony Qu <[email protected]> Date: Wed Apr 24 03:58:13 2024 +0800 Merge pull request nissl-lab#1307 from Bykiev/DocVars Fix reading document variables commit 976c1f5 Merge: 3412b21 428a170 Author: Tony Qu <[email protected]> Date: Wed Apr 24 03:55:07 2024 +0800 Merge pull request nissl-lab#1262 from jake-codes-at-5-am/removedatavalidation-to-upstream Add RemoveDataValidation method commit 3412b21 Merge: 4eb5d0e 7c65a61 Author: Tony Qu <[email protected]> Date: Wed Apr 24 03:53:27 2024 +0800 Merge pull request nissl-lab#1314 from antony-liu/fix/github-issue-1070 Avoid NullReference exception when saving workbook with XML Map commit 4eb5d0e Merge: 9e6eef1 44de724 Author: Tony Qu <[email protected]> Date: Thu Apr 18 08:13:11 2024 +0800 Merge pull request nissl-lab#1317 from DontFretBrett/update-sixlabors-imagesharp-218 Update SixLabors.ImageSharp to 2.1.8. CVE-2024-32036 commit 44de724 Author: Brett Sanders <[email protected]> Date: Wed Apr 17 10:53:37 2024 -0700 Update SixLabors.ImageSharp to 2.1.8. CVE-2024-32036 commit 9e6eef1 Merge: 595ed45 6321d89 Author: Tony Qu <[email protected]> Date: Tue Apr 16 22:31:48 2024 +0800 Merge branch 'master' of https://github.com/nissl-lab/npoi commit 595ed45 Author: Tony Qu <[email protected]> Date: Tue Apr 16 22:31:38 2024 +0800 fix TestXWPFRun unit test commit 6321d89 Merge: a8a827f 1067d7f Author: Tony Qu <[email protected]> Date: Tue Apr 16 09:05:17 2024 +0800 Merge pull request nissl-lab#1313 from Bykiev/SharpZipLib Update SharpZipLib to v1.4.2 commit a8a827f Merge: f0b0ea8 79dfd75 Author: Tony Qu <[email protected]> Date: Tue Apr 16 09:04:05 2024 +0800 Merge pull request nissl-lab#1283 from superrnovae/table_cellreferences [github-164] Fix Bug in XSSFTable.setCellReferences when table is single cell. commit f0b0ea8 Merge: 174fc67 16b283d Author: Tony Qu <[email protected]> Date: Tue Apr 16 09:02:16 2024 +0800 Merge pull request nissl-lab#1309 from antony-liu/poi/v3.16-patch2 Patches about VBAMacroReader from poi commit 174fc67 Merge: d31d5d3 649c565 Author: Tony Qu <[email protected]> Date: Tue Apr 16 08:47:24 2024 +0800 Merge branch 'master' of https://github.com/nissl-lab/npoi commit d31d5d3 Author: Tony Qu <[email protected]> Date: Tue Apr 16 08:46:58 2024 +0800 adjust Word openxml serialization commit 990e862 Author: Tony Qu <[email protected]> Date: Tue Apr 16 08:45:20 2024 +0800 only add xml:space="preserve" when the value starts or ends with whitespace commit 590b7f7 Author: Tony Qu <[email protected]> Date: Tue Apr 16 08:42:58 2024 +0800 fix nissl-lab#1276 - remove docGrid init code in CT_SectPr constructor commit 7c65a61 Author: Antony Liu <[email protected]> Date: Sat Apr 13 15:30:16 2024 +0800 Fix issue nissl-lab#1070, avoid NullReference exception when saving workbook with XML Map commit 1067d7f Author: ABykiev <[email protected]> Date: Tue Apr 9 18:51:36 2024 +0300 Update SharpZipLib to v1.4.2 Closes nissl-lab#1149 commit 16b283d Merge: 8f43183 649c565 Author: Antony Liu <[email protected]> Date: Fri Apr 5 09:58:46 2024 +0800 Merge branch 'master' into poi/v3.16-patch2 commit 649c565 Merge: 17041e5 7c89ee6 Author: Tony Qu <[email protected]> Date: Fri Apr 5 09:22:04 2024 +0800 Merge pull request nissl-lab#1306 from antony-liu/poi/v3.16-patch1 Some patches ported from poi commit 17041e5 Merge: 462f15f b89af43 Author: Tony Qu <[email protected]> Date: Wed Apr 3 07:35:01 2024 +0800 Merge pull request nissl-lab#1291 from jake-codes-at-5-am/fix-ct-formulacell-write CT_CellFormula.Write: fix writing the si attribute commit 7892c92 Author: ABykiev <[email protected]> Date: Tue Apr 2 21:58:45 2024 +0300 Fix reading document variables Closes nissl-lab#1199 commit c0378c6 Author: ABykiev <[email protected]> Date: Sun Mar 31 20:31:09 2024 +0300 XLS - Fix adding cell comment Closes nissl-lab#1240 commit 462f15f Author: Tony Qu <[email protected]> Date: Thu Mar 28 11:09:26 2024 +0800 Update FUNDING.yml commit 766e2c5 Author: Tony Qu <[email protected]> Date: Thu Mar 28 11:07:55 2024 +0800 Create FUNDING.yml commit 844391f Author: Tony Qu <[email protected]> Date: Thu Mar 28 11:00:17 2024 +0800 Delete .github/FUNDING.yml commit b89af43 Author: Artem Koloskov <[email protected]> Date: Tue Mar 12 15:27:58 2024 +0700 upstream-fix: in `CT_CellFormula` ensure the `siField` is written into `fField`'s attributes on `Write` even when it has a default value for cases when the type of the formula is Shared formula. commit b48fe66 Author: suppernovae <[email protected]> Date: Tue Mar 5 13:08:05 2024 +0100 Fix saving existing workbook with pictures after adding new ones commit 79dfd75 Author: suppernovae <[email protected]> Date: Tue Mar 5 11:43:26 2024 +0100 [github-164] Fix Bug in XSSFTable.setCellReferences when table is single cell commit 9fe58ed Author: suppernovae <[email protected]> Date: Tue Mar 5 10:48:34 2024 +0100 Revert "Use range operator instead of substring method" This reverts commit 5b838ba. commit 5b838ba Author: suppernovae <[email protected]> Date: Tue Mar 5 10:41:42 2024 +0100 Use range operator instead of substring method commit e5e92af Author: suppernovae <[email protected]> Date: Mon Mar 4 23:36:35 2024 +0100 Bug 67784: XSSFExcelExtractor does not format formula results like the streaming based extractor commit 428a170 Author: Artem Koloskov <[email protected]> Date: Fri Feb 9 11:31:06 2024 +0700 Upstream feature: change RemoveValidationData methods to RemoveDataValidation commit a39833e Author: Artem Koloskov <[email protected]> Date: Tue Nov 28 16:45:29 2023 +0700 Upstream feature: add tests for ISheet.RemoveValidationData method commit fefe574 Author: Artem Koloskov <[email protected]> Date: Tue Nov 28 16:44:37 2023 +0700 Upstream fix: fix CT_DataValidations.Write method. It was writing an empty dataValidations node if its dataValidation property was empty, which was breaking the resulting xlsx file commit 8e4b633 Author: Artem Koloskov <[email protected]> Date: Tue Nov 28 16:41:54 2023 +0700 Upstream feature: ass ISheet.RemoveValidationData method and implement it in HSSF, XSSF and SXSSF Sheets commit 73daa01 Author: Artem Koloskov <[email protected]> Date: Tue Nov 28 16:40:21 2023 +0700 Upstream feature: implement DataValidityTable.RemoveDataValidation method commit 01c9fa5 Author: Artem Koloskov <[email protected]> Date: Tue Nov 28 16:38:03 2023 +0700 Upstream feature: Implement CT_DataValidation and DVRecord Equals() method overrides.
1 parent 1212e24 commit 2015bb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1060
-531
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
custom: ["https://www.paypal.me/tonyqus"]
1+
github: nissl-lab

OpenXmlFormats/Drawing/WordprocessingDrawing.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ public static CT_Inline Parse(XmlNode node, XmlNamespaceManager namespaceManager
444444
if (node == null)
445445
return null;
446446
CT_Inline ctObj = new CT_Inline();
447-
ctObj.distT = XmlHelper.ReadUInt(node.Attributes["wp:distT"]);
448-
ctObj.distB = XmlHelper.ReadUInt(node.Attributes["wp:distB"]);
449-
ctObj.distL = XmlHelper.ReadUInt(node.Attributes["wp:distL"]);
450-
ctObj.distR = XmlHelper.ReadUInt(node.Attributes["wp:distR"]);
447+
ctObj.distT = XmlHelper.ReadUInt(node.Attributes["distT"]);
448+
ctObj.distB = XmlHelper.ReadUInt(node.Attributes["distB"]);
449+
ctObj.distL = XmlHelper.ReadUInt(node.Attributes["distL"]);
450+
ctObj.distR = XmlHelper.ReadUInt(node.Attributes["distR"]);
451451
foreach (XmlNode childNode in node.ChildNodes)
452452
{
453453
if (childNode.LocalName == "extent")

OpenXmlFormats/Spreadsheet/CustomXmlMappings.cs

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
using NPOI.OpenXml4Net.Util;
12
using System;
23
using System.Collections.Generic;
34
using System.ComponentModel;
45
using System.Diagnostics;
6+
using System.IO;
57
using System.Xml;
68
using System.Xml.Serialization;
79

@@ -23,6 +25,40 @@ public class CT_MapInfo
2325

2426
private string selectionNamespacesField = string.Empty; // 1..1
2527

28+
public static CT_MapInfo Parse(XmlNode node, XmlNamespaceManager namespaceManager)
29+
{
30+
CT_MapInfo ctObj = new CT_MapInfo();
31+
ctObj.SelectionNamespaces = XmlHelper.ReadString(node.Attributes["SelectionNamespaces"]);
32+
foreach(XmlNode cn in node.ChildNodes)
33+
{
34+
if(cn.LocalName == "Schema")
35+
{
36+
ctObj.Schema.Add(CT_Schema.Parse(cn, namespaceManager));
37+
}
38+
else if(cn.LocalName == "Map")
39+
{
40+
ctObj.Map.Add(CT_Map.Parse(cn, namespaceManager));
41+
}
42+
}
43+
return ctObj;
44+
}
45+
46+
internal void Write(StreamWriter sw, string nodeName)
47+
{
48+
sw.Write(string.Format("<{0}", nodeName));
49+
XmlHelper.WriteAttribute(sw, "SelectionNamespaces", this.SelectionNamespaces);
50+
sw.Write(">");
51+
foreach(CT_Schema ctSchema in Schema)
52+
{
53+
ctSchema.Write(sw, "Schema");
54+
}
55+
56+
foreach(CT_Map ctMap in Map)
57+
{
58+
ctMap.Write(sw, "Map");
59+
}
60+
sw.Write(string.Format("</{0}>", nodeName));
61+
}
2662
[XmlElement("Schema")]
2763
public List<CT_Schema> Schema
2864
{
@@ -77,6 +113,30 @@ public class CT_Schema
77113

78114
private string namespaceField = null; // 0..1
79115

116+
private string schemaLanguageField;
117+
118+
public static CT_Schema Parse(XmlNode node, XmlNamespaceManager namespaceManager)
119+
{
120+
CT_Schema ctObj = new CT_Schema();
121+
ctObj.ID = node.Attributes["ID"].Value;
122+
ctObj.Namespace = XmlHelper.ReadString(node.Attributes["Namespace"]);
123+
ctObj.SchemaRef = XmlHelper.ReadString(node.Attributes["SchemaRef"]);
124+
ctObj.SchemaLanguage = XmlHelper.ReadString(node.Attributes["SchemaLanguage"]);
125+
ctObj.Any = node.FirstChild as XmlElement;
126+
return ctObj;
127+
}
128+
internal void Write(StreamWriter sw, string nodeName)
129+
{
130+
sw.Write(string.Format("<{0}", nodeName));
131+
XmlHelper.WriteAttribute(sw, "ID", this.ID);
132+
XmlHelper.WriteAttribute(sw, "Namespace", this.Namespace);
133+
XmlHelper.WriteAttribute(sw, "SchemaRef", this.SchemaRef);
134+
XmlHelper.WriteAttribute(sw, "SchemaLanguage", this.SchemaLanguage);
135+
sw.Write(">");
136+
if(anyField != null)
137+
sw.Write(anyField.OuterXml);
138+
sw.Write(string.Format("</{0}>", nodeName));
139+
}
80140
[XmlAnyElement]
81141
public System.Xml.XmlElement Any
82142
{
@@ -144,7 +204,23 @@ public bool NamespaceSpecified
144204
get { return null != this.namespaceField; }
145205
}
146206

147-
public string InnerXml;
207+
public string SchemaLanguage
208+
{
209+
get
210+
{
211+
return this.schemaLanguageField;
212+
}
213+
set
214+
{
215+
schemaLanguageField = value;
216+
}
217+
}
218+
219+
[XmlIgnore]
220+
public bool SchemaLanguageSpecified
221+
{
222+
get { return null != this.schemaLanguageField; }
223+
}
148224
}
149225

150226

@@ -176,6 +252,49 @@ public class CT_Map
176252

177253
private bool preserveFormatField;
178254

255+
public static CT_Map Parse(XmlNode node, XmlNamespaceManager namespaceManager)
256+
{
257+
CT_Map ctMap = new CT_Map();
258+
ctMap.ID = XmlHelper.ReadUInt(node.Attributes["ID"]);
259+
ctMap.Name = XmlHelper.ReadString(node.Attributes["Name"]);
260+
ctMap.RootElement = XmlHelper.ReadString(node.Attributes["RootElement"]);
261+
ctMap.SchemaID = XmlHelper.ReadString(node.Attributes["SchemaID"]);
262+
ctMap.ShowImportExportValidationErrors = XmlHelper.ReadBool(node.Attributes["ShowImportExportValidationErrors"]);
263+
ctMap.PreserveFormat = XmlHelper.ReadBool(node.Attributes["PreserveFormat"]);
264+
ctMap.PreserveSortAFLayout = XmlHelper.ReadBool(node.Attributes["PreserveSortAFLayout"]);
265+
ctMap.Append = XmlHelper.ReadBool(node.Attributes["Append"]);
266+
ctMap.AutoFit = XmlHelper.ReadBool(node.Attributes["AutoFit"]);
267+
foreach(XmlElement ele in node)
268+
{
269+
if(ele.LocalName == "DataBinding")
270+
{
271+
ctMap.DataBinding = CT_DataBinding.Parse(ele, namespaceManager);
272+
}
273+
}
274+
return ctMap;
275+
}
276+
internal void Write(StreamWriter sw, string nodeName)
277+
{
278+
sw.Write(string.Format("<{0}", nodeName));
279+
XmlHelper.WriteAttribute(sw, "ID", this.ID);
280+
XmlHelper.WriteAttribute(sw, "Name", this.Name);
281+
XmlHelper.WriteAttribute(sw, "RootElement", this.RootElement);
282+
XmlHelper.WriteAttribute(sw, "SchemaID", this.SchemaID);
283+
XmlHelper.WriteAttribute(sw, "ShowImportExportValidationErrors", this.ShowImportExportValidationErrors);
284+
XmlHelper.WriteAttribute(sw, "PreserveFormat", this.PreserveFormat);
285+
XmlHelper.WriteAttribute(sw, "PreserveSortAFLayout", this.PreserveSortAFLayout);
286+
XmlHelper.WriteAttribute(sw, "Append", this.Append);
287+
XmlHelper.WriteAttribute(sw, "AutoFit", this.AutoFit);
288+
289+
if(dataBindingField != null)
290+
{
291+
sw.Write(">");
292+
dataBindingField.Write(sw, "DataBinding");
293+
sw.Write(string.Format("</{0}>", nodeName));
294+
}
295+
else
296+
sw.Write("/>");
297+
}
179298
[XmlElement]
180299
public CT_DataBinding DataBinding
181300
{
@@ -343,7 +462,33 @@ public partial class CT_DataBinding
343462

344463
private uint dataBindingLoadModeField = 0; // 1..1 - default value not defined in xsd
345464

465+
public static CT_DataBinding Parse(XmlNode ele, XmlNamespaceManager namespaceManager)
466+
{
467+
CT_DataBinding ctObj = new CT_DataBinding();
468+
ctObj.Any = ele.FirstChild as XmlElement;
469+
ctObj.connectionIDField = ele.Attributes["ConnectionID"] ==null ? null : XmlHelper.ReadUInt(ele.Attributes["ConnectionID"]);
470+
ctObj.DataBindingName = XmlHelper.ReadString(ele.Attributes["DataBindingName"]);
471+
ctObj.FileBindingName = XmlHelper.ReadString(ele.Attributes["FileBindingName"]);
472+
ctObj.DataBindingLoadMode = XmlHelper.ReadUInt(ele.Attributes["DataBindingLoadMode"]);
473+
ctObj.fileBindingField = ele.Attributes["FileBinding"] ==null ? null : XmlHelper.ReadBool(ele.Attributes["FileBinding"]);
474+
return ctObj;
475+
}
346476

477+
internal void Write(StreamWriter sw, string nodeName)
478+
{
479+
sw.Write(string.Format("<{0}", nodeName));
480+
if(this.FileBindingSpecified)
481+
XmlHelper.WriteAttribute(sw, "FileBinding", FileBinding);
482+
if(this.ConnectionIDSpecified)
483+
XmlHelper.WriteAttribute(sw, "ConnectionID", ConnectionID);
484+
XmlHelper.WriteAttribute(sw, "DataBindingLoadMode", DataBindingLoadMode);
485+
XmlHelper.WriteAttribute(sw, "DataBindingName", DataBindingName);
486+
XmlHelper.WriteAttribute(sw, "FileBindingName", FileBindingName);
487+
sw.Write(">");
488+
if(anyField != null)
489+
sw.Write(anyField.OuterXml);
490+
sw.Write(string.Format("</{0}>", nodeName));
491+
}
347492
[XmlAnyElement]
348493
public System.Xml.XmlElement Any
349494
{

OpenXmlFormats/Spreadsheet/Document/MapInfoDocument.cs

Lines changed: 9 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,105 +7,40 @@ namespace NPOI.OpenXmlFormats.Spreadsheet
77
{
88
public class MapInfoDocument
99
{
10-
CT_MapInfo map = null;
10+
CT_MapInfo mapInfo = null;
1111

1212
public MapInfoDocument()
1313
{
1414
}
1515
public MapInfoDocument(CT_MapInfo map)
1616
{
17-
this.map = map;
17+
this.mapInfo = map;
1818
}
1919
public CT_MapInfo GetMapInfo()
2020
{
21-
return this.map;
21+
return this.mapInfo;
2222
}
2323
public void SetMapInfo(CT_MapInfo map)
2424
{
25-
this.map = map;
25+
this.mapInfo = map;
2626
}
2727
public void SetComments(CT_MapInfo map)
2828
{
29-
this.map = map;
29+
this.mapInfo = map;
3030
}
31+
public string SelectionNamespaces { get; set; }
3132
public void Save(Stream stream)
3233
{
3334
using (StreamWriter sw = new StreamWriter(stream))
3435
{
35-
sw.Write("<MapInfo xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" SelectionNamespaces=\"xmlns:ns1='http://schemas.openxmlformats.org/spreadsheetml/2006/main'\">");
36-
if (this.map.Schema != null)
37-
{
38-
foreach (CT_Schema ctSchema in this.map.Schema)
39-
{
40-
sw.Write(string.Format("<Schema ID=\"{0}\"", ctSchema.ID));
41-
if (ctSchema.Namespace != null)
42-
sw.Write(string.Format(" Namespace=\"{0}\"", ctSchema.Namespace));
43-
if (ctSchema.SchemaRef != null)
44-
sw.Write(string.Format(" SchemaRef=\"{0}\"", ctSchema.SchemaRef));
45-
sw.Write(">");
46-
sw.Write(ctSchema.InnerXml);
47-
sw.Write("</Schema>");
48-
}
49-
}
50-
if (this.map.Map != null)
51-
{
52-
foreach (CT_Map ctMap in this.map.Map)
53-
{
54-
sw.Write(string.Format("<Map ID=\"{0}\"", ctMap.ID));
55-
if (ctMap.SchemaID != null)
56-
sw.Write(string.Format(" SchemaID=\"{0}\"", ctMap.SchemaID));
57-
if (ctMap.RootElement != null)
58-
sw.Write(string.Format(" RootElement=\"{0}\"", ctMap.RootElement));
59-
if (ctMap.Name != null)
60-
sw.Write(string.Format(" Name=\"{0}\"", ctMap.Name));
61-
if (ctMap.PreserveFormat)
62-
sw.Write(" PreserveFormat=\"true\"");
63-
if (ctMap.PreserveSortAFLayout)
64-
sw.Write(" PreserveSortAFLayout=\"true\"");
65-
if (ctMap.ShowImportExportValidationErrors)
66-
sw.Write(" ShowImportExportValidationErrors=\"true\"");
67-
if (ctMap.Append)
68-
sw.Write(" Append=\"true\"");
69-
if (ctMap.AutoFit)
70-
sw.Write(" AutoFit=\"true\"");
71-
sw.Write(" />");
72-
}
73-
}
74-
sw.Write("</MapInfo");
36+
mapInfo.Write(sw, "MapInfo");
7537
}
7638
}
7739

78-
public static MapInfoDocument Parse(System.Xml.XmlDocument xmldoc, System.Xml.XmlNamespaceManager NameSpaceManager)
40+
public static MapInfoDocument Parse(XmlDocument xmlDoc, XmlNamespaceManager nameSpaceManager)
7941
{
8042
MapInfoDocument doc = new MapInfoDocument();
81-
doc.map = new CT_MapInfo();
82-
doc.map.Map = new System.Collections.Generic.List<CT_Map>();
83-
foreach (XmlElement mapNode in xmldoc.SelectNodes("d:MapInfo/d:Map", NameSpaceManager))
84-
{
85-
CT_Map ctMap=new CT_Map();
86-
ctMap.ID = XmlHelper.ReadUInt(mapNode.GetAttributeNode("ID"));
87-
ctMap.Name = XmlHelper.ReadString(mapNode.GetAttributeNode("Name"));
88-
ctMap.RootElement = XmlHelper.ReadString(mapNode.GetAttributeNode("RootElement"));
89-
ctMap.SchemaID = XmlHelper.ReadString(mapNode.GetAttributeNode("SchemaID"));
90-
ctMap.ShowImportExportValidationErrors = XmlHelper.ReadBool(mapNode.GetAttributeNode("ShowImportExportValidationErrors"));
91-
ctMap.PreserveFormat = XmlHelper.ReadBool(mapNode.GetAttributeNode("PreserveFormat"));
92-
ctMap.PreserveSortAFLayout = XmlHelper.ReadBool(mapNode.GetAttributeNode("PreserveSortAFLayout"));
93-
ctMap.Append = XmlHelper.ReadBool(mapNode.GetAttributeNode("Append"));
94-
ctMap.AutoFit = XmlHelper.ReadBool(mapNode.GetAttributeNode("AutoFit"));
95-
doc.map.Map.Add(ctMap);
96-
}
97-
doc.map.Schema = new System.Collections.Generic.List<CT_Schema>();
98-
foreach (XmlNode schemaNode in xmldoc.SelectNodes("d:MapInfo/d:Schema", NameSpaceManager))
99-
{
100-
CT_Schema ctSchema = new CT_Schema();
101-
ctSchema.ID = schemaNode.Attributes["ID"].Value;
102-
if (schemaNode.Attributes["Namespace"] != null)
103-
ctSchema.Namespace = schemaNode.Attributes["Namespace"].Value;
104-
if (schemaNode.Attributes["SchemaRef"] != null)
105-
ctSchema.SchemaRef = schemaNode.Attributes["SchemaRef"].Value;
106-
ctSchema.InnerXml = schemaNode.InnerXml;
107-
doc.map.Schema.Add(ctSchema);
108-
}
43+
doc.mapInfo = CT_MapInfo.Parse(xmlDoc.DocumentElement, nameSpaceManager);
10944
return doc;
11045
}
11146
}

OpenXmlFormats/Spreadsheet/Sheet.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,14 +2694,14 @@ internal void Write(StreamWriter sw, string nodeName)
26942694
XmlHelper.WriteAttribute(sw, "t", this.t.ToString());
26952695
XmlHelper.WriteAttribute(sw, "aca", this.aca, false);
26962696
XmlHelper.WriteAttribute(sw, "ref", this.@ref);
2697-
XmlHelper.WriteAttribute(sw, "dt2D", this.dt2D, true);
2698-
XmlHelper.WriteAttribute(sw, "dtr", this.dtr, true);
2697+
XmlHelper.WriteAttribute(sw, "dt2D", this.dt2D, false);
2698+
XmlHelper.WriteAttribute(sw, "dtr", this.dtr, false);
26992699
XmlHelper.WriteAttribute(sw, "del1", this.del1, false);
27002700
XmlHelper.WriteAttribute(sw, "del2", this.del2, false);
27012701
XmlHelper.WriteAttribute(sw, "r1", this.r1);
27022702
XmlHelper.WriteAttribute(sw, "r2", this.r2);
27032703
XmlHelper.WriteAttribute(sw, "ca", this.ca, false);
2704-
if(this.si!=0)
2704+
if(this.t == ST_CellFormulaType.shared || this.si!=0)
27052705
XmlHelper.WriteAttribute(sw, "si", this.si, true);
27062706
XmlHelper.WriteAttribute(sw, "bx", this.bx, false);
27072707
if (!string.IsNullOrEmpty(this.valueField))
@@ -7133,6 +7133,8 @@ public static CT_DataValidations Parse(XmlNode node, XmlNamespaceManager namespa
71337133

71347134
internal void Write(StreamWriter sw, string nodeName)
71357135
{
7136+
if (this.countField == 0)
7137+
return;
71367138
sw.Write(string.Format("<{0}", nodeName));
71377139
XmlHelper.WriteAttribute(sw, "disablePrompts", this.disablePrompts);
71387140
XmlHelper.WriteAttribute(sw, "xWindow", this.xWindow);
@@ -7387,6 +7389,33 @@ public void Set(CT_DataValidation obj)
73877389
promptField = obj.promptField;
73887390
sqrefField = obj.sqrefField;
73897391
}
7392+
7393+
public override bool Equals(object obj)
7394+
{
7395+
CT_DataValidation o = (CT_DataValidation)obj;
7396+
7397+
if (o is null)
7398+
{
7399+
return false;
7400+
}
7401+
7402+
return formula1Field == o.formula1Field
7403+
&& formula2Field == o.formula2Field
7404+
&& typeField == o.typeField
7405+
&& errorStyleField == o.errorStyleField
7406+
&& imeModeField == o.imeModeField
7407+
&& operatorField == o.operatorField
7408+
&& allowBlankField == o.allowBlankField
7409+
&& showDropDownField == o.showDropDownField
7410+
&& showInputMessageField == o.showInputMessageField
7411+
&& showErrorMessageField == o.showErrorMessageField
7412+
&& errorTitleField == o.errorTitleField
7413+
&& errorField == o.errorField
7414+
&& promptTitleField == o.promptTitleField
7415+
&& promptField == o.promptField
7416+
&& sqrefField == o.sqrefField;
7417+
}
7418+
73907419
[XmlElement(Order = 0)]
73917420
public string formula1
73927421
{

0 commit comments

Comments
 (0)