diff --git a/OpenXmlFormats/Spreadsheet/Styles/CT_CellStyleXfs.cs b/OpenXmlFormats/Spreadsheet/Styles/CT_CellStyleXfs.cs index 6f851840a..5338b84c2 100644 --- a/OpenXmlFormats/Spreadsheet/Styles/CT_CellStyleXfs.cs +++ b/OpenXmlFormats/Spreadsheet/Styles/CT_CellStyleXfs.cs @@ -44,7 +44,7 @@ internal void Write(StreamWriter sw, string nodeName) { foreach (CT_Xf x in this.xf) { - x.Write(sw, "xf"); + x.Write(sw, "xf", true); } } sw.Write(string.Format("", nodeName)); diff --git a/OpenXmlFormats/Spreadsheet/Styles/CT_Xf.cs b/OpenXmlFormats/Spreadsheet/Styles/CT_Xf.cs index 621251dd7..3ae3e75cf 100644 --- a/OpenXmlFormats/Spreadsheet/Styles/CT_Xf.cs +++ b/OpenXmlFormats/Spreadsheet/Styles/CT_Xf.cs @@ -109,14 +109,15 @@ public static CT_Xf Parse(XmlNode node, XmlNamespaceManager namespaceManager) - internal void Write(StreamWriter sw, string nodeName) + internal void Write(StreamWriter sw, string nodeName, bool writingCellStyle=false) { sw.Write(string.Format("<{0}", nodeName)); XmlHelper.WriteAttribute(sw, "numFmtId", this.numFmtId, true); XmlHelper.WriteAttribute(sw, "fontId", this.fontId, true); XmlHelper.WriteAttribute(sw, "fillId", this.fillId, true); XmlHelper.WriteAttribute(sw, "borderId", this.borderId, true); - XmlHelper.WriteAttribute(sw, "xfId", this.xfId, true); + if (!writingCellStyle) + XmlHelper.WriteAttribute(sw, "xfId", this.xfId, true); XmlHelper.WriteAttribute(sw, "quotePrefix", this.quotePrefix,false); XmlHelper.WriteAttribute(sw, "pivotButton", this.pivotButton, false); if(this.applyNumberFormat)