i have an excel in the format :
col1 col2 col3 col4 col5
Row 1: 1 Head data1 r11 r12
Row 2: 1 Head data2 r21 r22
Row 3: 1 Head data3 r31 r32
Row 4: 1 Head data4 r41 r42
Row 5: 1 Head data5 r51 r52
Row 6: 1 Head2 data6 r61 r62
Row 7: 1 Head2 data7 r71 r72
Row 8: 1 Head2 data7 r81 r82
Row 9: 1 Head2 data8 r91 r92
Row 10: 1 Head2 data9 r101 r102
Row 11: 1 Head2 data10 r111 r112
Row 12: 1 Head2 data11 r121 r122
Row 13: 1 Head2 data12 r131 r132
Row 14: 1 Head2 data13 r141 r142
the above excel is such that the consecutive same values means they are merged.
The merged cells are
" Row1col1 to Row14col1" with value :"1"
" Row1col2 to Row5col2" with value : "Head"
"Row6Col2 to Row14col2" with value : "Head2"
reading an excel without any merged cells can be done through OLEDb like this;
OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$] ", connection);
connection.Open();
XmlDocument doc = new XmlDocument();
But how to read merged cells and to format it into an xml like this;
A node Head with subnodes data1 to data6 and each subnodes have the concatenation of col4 and col5.
Eg:
<node name="Head">
<subnode name="data1" sum="r11+r12"></subnode>
<subnode name="data2" sum="r21+r22"></subnode>
and so on....
EDIT2
Output as per @lloydm is this:
<node>
<subnode name="Head" sum="data1r11" />
<subnode name="" sum="data2r21" />
<subnode name="" sum="data3r31" />
<subnode name="" sum="data4r41" />
<subnode name="" sum="data5r51" />
<subnode name="Head2" sum="data6r61" />
<subnode name="" sum="data7r71" />
<subnode name="" sum="data8r81" />
<subnode name="" sum="data9r91" />
</node>
So, how shall i get an output like:
<node>
<subnode name="Head" />
<subsubnode name="data2" sum="data2r21" />
<subsubnode name="data3" sum="data3r31" />
<subsubnode name="data4" sum="data4r41" />
etc...
</subnode>
<subnode name="Head2" />
<subsubnode name="data2" sum="data2r21" />
<subsubnode name="data3" sum="data3r31" />
<subsubnode name="data4" sum="data4r41" />
etc...
</subnode>
</node>