void ExportContent(XmlWriter writer) { // Has formula? if (Content == ContentType.Formula) { writer.WriteAttributeString("ss", "Formula", null, "=" + formula.ToString(this)); } else if (Content == ContentType.UnresolvedValue) { writer.WriteAttributeString("ss", "Formula", null, (string)_value); } else if (Content != ContentType.None) { // Write Data writer.WriteStartElement("Data"); writer.WriteAttributeString("ss", "Type", null, Content.ToString()); switch (Content) { case ContentType.Boolean: { if ((bool)_value) { writer.WriteValue("1"); } else { writer.WriteValue("0"); } break; } case ContentType.DateTime: { writer.WriteValue(((DateTime)_value).ToString("yyyy-MM-dd\\Thh:mm:ss.fff", CultureInfo.InvariantCulture)); break; } case ContentType.Number: { decimal d = Convert.ToDecimal(_value, CultureInfo.InvariantCulture); writer.WriteValue(d.ToString(new CultureInfo("en-US"))); break; } case ContentType.String: { writer.WriteValue((string)_value); break; } } writer.WriteEndElement(); } }
internal string ToString(Cell cell) { StringBuilder parameterList = new StringBuilder(); foreach (Parameter p in Parameters) { switch (p.ParameterType) { case ParameterType.Range: Range range = p.Value as Range; if (range != null) { parameterList.Append(range.RangeReference(cell)); } break; case ParameterType.Formula: Formula formula = p.Value as Formula; if (formula != null) { parameterList.Append(formula.ToString(cell)); } break; case ParameterType.String: parameterList.Append(p.Value.ToString()); break; } } if (MustHaveParameters && (Parameters.Count == 0 || parameterList.Length == 0)) { return(""); } return(parameterList.ToString()); }