internal void Export(XmlWriter writer, bool printIndex) { if (IsEmpty()) { return; } if (!MergeStart && ParentRow.ParentSheet.IsCellMerged(this)) { return; } writer.WriteStartElement("Cell"); if (!StyleID.IsNullOrEmpty() && ParentRow.StyleID != StyleID && StyleID != "Default") { writer.WriteAttributeString("ss", "StyleID", null, StyleID); } if (printIndex) { writer.WriteAttributeString("ss", "Index", null, (CellIndex + 1).ToString(CultureInfo.InvariantCulture)); } if (!HRef.IsNullOrEmpty()) { writer.WriteAttributeString("ss", "HRef", null, HRef.XmlEncode()); } if (MergeStart) { Worksheet ws = ParentRow.ParentSheet; Range range = ws._MergedCells.Find(rangeToFind => rangeToFind.CellFrom == this); if (range != null) { int rangeCols = range.ColumnCount - 1; int rangeRows = range.RowCount - 1; if (rangeCols > 0) { writer.WriteAttributeString("ss", "MergeAcross", null, rangeCols.ToString(CultureInfo.InvariantCulture)); } if (rangeRows > 0) { writer.WriteAttributeString("ss", "MergeDown", null, rangeRows.ToString(CultureInfo.InvariantCulture)); } } } ExportContent(writer); ExportComment(writer); List <string> namedRanges = GetParentBook().CellInNamedRanges(this); foreach (string range in namedRanges) { writer.WriteStartElement("NamedCell"); writer.WriteAttributeString("ss", "Name", null, range); writer.WriteEndElement(); } writer.WriteEndElement(); }
internal void Export(XmlWriter writer, bool printIndex) { if (IsEmpty()) { return; } // If no merge starts from this cell, and this cells is in // a merged range, no output should be done... if (!MergeStart && ParentRow.ParentSheet.IsCellMerged(this)) { return; } // Start Cell writer.WriteStartElement("Cell"); // Has style? If yes, we only need to write the style if default line // style is not same as this one... if (!StyleID.IsNullOrEmpty() && ParentRow.StyleID != StyleID && StyleID != "Default") { writer.WriteAttributeString("ss", "StyleID", null, StyleID); } if (printIndex) { writer.WriteAttributeString("ss", "Index", null, (CellIndex + 1).ToString(CultureInfo.InvariantCulture)); } if (!HRef.IsNullOrEmpty()) { writer.WriteAttributeString("ss", "HRef", null, HRef.XmlEncode()); } if (MergeStart) { Worksheet ws = ParentRow.ParentSheet; Range range = ws._MergedCells.Find(rangeToFind => rangeToFind.CellFrom == this); if (range != null) { int rangeCols = range.ColumnCount - 1; int rangeRows = range.RowCount - 1; if (rangeCols > 0) { writer.WriteAttributeString("ss", "MergeAcross", null, rangeCols.ToString(CultureInfo.InvariantCulture)); } if (rangeRows > 0) { writer.WriteAttributeString("ss", "MergeDown", null, rangeRows.ToString(CultureInfo.InvariantCulture)); } } } // Export content ExportContent(writer); // Export comment ExportComment(writer); // Write named ranges List <string> namedRanges = GetParentBook().CellInNamedRanges(this); foreach (string range in namedRanges) { writer.WriteStartElement("NamedCell"); writer.WriteAttributeString("ss", "Name", null, range); writer.WriteEndElement(); } // End Cell writer.WriteEndElement(); }