//开始一个新行
public static void WriteStartRow(XmlWriter writer, int row)
{
writer.WriteStartElement(Prefixes.SpreadsheetML, "row",
Namespaces.SpreadsheetML);
writer.WriteAttributeString("r", row.ToString());
}
//添加内容为文本的单元格
public static void WriteStringCell(XmlWriter writer, string column, int row, string text)
{
writer.WriteStartElement(Prefixes.SpreadsheetML, "c",
Namespaces.SpreadsheetML);
writer.WriteAttributeString("r", column + row.ToString());
writer.WriteAttributeString("t", "s");
int stringIndex = SharedStrings.LookupString(text);
writer.WriteElementString(Prefixes.SpreadsheetML, "v",
Namespaces.SpreadsheetML, stringIndex.ToString());
writer.WriteEndElement();
}
//添加内容为数字的单于格
public static void WriteNumberCell(XmlWriter writer, string column, int row, decimal value)
{
writer.WriteStartElement(Prefixes.SpreadsheetML, "c",
Namespaces.SpreadsheetML);
writer.WriteAttributeString("r", column + row.ToString());
writer.WriteElementString(Prefixes.SpreadsheetML, "v",
Namespaces.SpreadsheetML, value.ToString("#0.00"));
writer.WriteEndElement();
}
//添加内容为公式的单元格
public static void WriteFormulaCell(XmlWriter writer, string column, int row, string formula)
{
writer.WriteStartElement(Prefixes.SpreadsheetML, "c",
Namespaces.SpreadsheetML);
writer.WriteAttributeString("r", column + row.ToString());
writer.WriteElementString(Prefixes.SpreadsheetML, "f",
Namespaces.SpreadsheetML, formula);
writer.WriteEndElement();
}