1

My program generates an Excel file using XmlTextWriter. I cannot find how exactly I could set colors of some cells (or even rows).

Here is some of my code:

    public static void CreateCell(XmlTextWriter w, object value)
    {
        w.WriteStartElement("Cell");
        w.WriteStartElement("Data");
        w.WriteAttributeString("ss", "Type", null, "String");

        w.WriteString(value.ToString());
        w.WriteEndElement();
        w.WriteEndElement();  
    }
David Shochet
  • 5,035
  • 11
  • 57
  • 105
  • Showing how desired XML should look like will make *this* question better. If you don't know how XML should look like you may want to rewrite the question or ask new one. – Alexei Levenkov Nov 08 '13 at 18:07
  • As I wrote, the result is an excel file. And the file is generated fine, I just need to be able to color some cells. It may be either background or foreground color, it does not matter. I don't know how the xml would look. But I am not sure it should be a separate question, as I am interested in the end result, i.e. color of a cell. – David Shochet Nov 08 '13 at 18:12
  • 1
    So go into Excel, create a cell with a color, and then output to XML. Examine the generated XML to see what the cell coloring looks like and then duplicate that in your code. – Jim Mischel Nov 08 '13 at 22:27
  • See also: http://stackoverflow.com/q/6670144/56778 – Jim Mischel Nov 08 '13 at 22:33
  • Thank you Jim. If you make your advice an Answer, I would mark it as such. – David Shochet Nov 11 '13 at 14:05

0 Answers0