G
Guest
I am increasingly frustrated and exasperated.
I am trying to generate SpreadsheetML using C#. CSV won't do because I need
formatting.
I have the Office 2003 XSD files but xsd.exe doesn't want to know about
them. So I am trying to hand construct a basic "hello world" spreadsheet
using XmlSerializer.
I have a number of problems:
1) XmlSerializer's handling of ICollection derived classes is horrible:
I need to generate something like this (some things omitted for clarity):
<Table>
<Row>
<Cell>blah blah blah</Cell>
<Cell>blah blah blah</Cell>
</Row>
<Row>
<Cell>blah blah blah</Cell>
<Cell>blah blah blah</Cell>
</Row>
</Table>
Putting
class Table
{
public Row []Rows;
}
class Row
{
public int something;
public Cell []Cells;
}
doesn't work, because that produces unwanted <Rows> and <Cells> tags. Using
ICollection as a base for TableType and RowType almost works, but insists on
putting <ArrayOfCell>, won't allow any metadata on Row and refuses to
seriaize the other attributes of Row.
2) XmlSerializer does not allow me to put xmlns="something" and
xmlns:ss="something"
3) XmlSerializer does not like the Style tag. Excel seems to insist that the
XML be <Style ss:ID="something">
rather than
<ss:Style ID="something">
which is what XmlSerializer wants to produce. There is no way (unless I am
mistaken) of forcing the ss: onto the ID.
4) It is unclear how to perform the following
<Cell>
<Data ss:Type="String">world</Data>
</Cell>
I can put
class Cell
{
public DataType Data;
}
class DataType
{
[XmlAttribute]
public string Type;
}
but then how do I get the actual data into the XML (in this case the word
"world")
5) The help built into Visual Studio 2003 is not up to Microsoft's usual
standard:
Example code of Xml Serialization should include the resulting Xml in the
help file. Duh!
6) It should be easy to work with Microsoft XML format using Microsoft
development tools. The fact that it isn't is very frustrating.
7) There is example code in C++, but none in C#.
I am trying to generate SpreadsheetML using C#. CSV won't do because I need
formatting.
I have the Office 2003 XSD files but xsd.exe doesn't want to know about
them. So I am trying to hand construct a basic "hello world" spreadsheet
using XmlSerializer.
I have a number of problems:
1) XmlSerializer's handling of ICollection derived classes is horrible:
I need to generate something like this (some things omitted for clarity):
<Table>
<Row>
<Cell>blah blah blah</Cell>
<Cell>blah blah blah</Cell>
</Row>
<Row>
<Cell>blah blah blah</Cell>
<Cell>blah blah blah</Cell>
</Row>
</Table>
Putting
class Table
{
public Row []Rows;
}
class Row
{
public int something;
public Cell []Cells;
}
doesn't work, because that produces unwanted <Rows> and <Cells> tags. Using
ICollection as a base for TableType and RowType almost works, but insists on
putting <ArrayOfCell>, won't allow any metadata on Row and refuses to
seriaize the other attributes of Row.
2) XmlSerializer does not allow me to put xmlns="something" and
xmlns:ss="something"
3) XmlSerializer does not like the Style tag. Excel seems to insist that the
XML be <Style ss:ID="something">
rather than
<ss:Style ID="something">
which is what XmlSerializer wants to produce. There is no way (unless I am
mistaken) of forcing the ss: onto the ID.
4) It is unclear how to perform the following
<Cell>
<Data ss:Type="String">world</Data>
</Cell>
I can put
class Cell
{
public DataType Data;
}
class DataType
{
[XmlAttribute]
public string Type;
}
but then how do I get the actual data into the XML (in this case the word
"world")
5) The help built into Visual Studio 2003 is not up to Microsoft's usual
standard:
Example code of Xml Serialization should include the resulting Xml in the
help file. Duh!
6) It should be easy to work with Microsoft XML format using Microsoft
development tools. The fact that it isn't is very frustrating.
7) There is example code in C++, but none in C#.