title: Datatable to xml with different schema
body: <p>I need to convert my datatable data to this schema (To be opened in MS Excel).</p>
  
  <h3> Datatable Schema</h3>
  
  <pre><code>ReferId    Name    Salary
  2457165     ABC    10000  
  </code></pre>
  
  <h3>Output Schema Example</h3>
  
  <pre><code>&lt;Worksheet ss:Name="Sheet1"&gt;
    &lt;ss:Table&gt;
     &lt;ss:Row&gt;
      &lt;ss:Cell  ss:StyleID="s27"&gt;&lt;Data ss:Type="String"&gt;Refer_ID&lt;/Data&gt;&lt;/ss:Cell&gt;
      &lt;ss:Cell  ss:StyleID="s27"&gt;&lt;Data ss:Type="String"&gt;Name&lt;/Data&gt;&lt;/ss:Cell&gt;
      &lt;ss:Cell  ss:StyleID="s27"&gt;&lt;Data ss:Type="String"&gt;Salary&lt;/Data&gt;&lt;/ss:Cell&gt;
     &lt;/ss:Row&gt;
     &lt;ss:Row&gt;
      &lt;ss:Cell&gt;&lt;Data ss:Type="String"&gt;2457165&lt;/Data&gt;&lt;/ss:Cell&gt;
      &lt;ss:Cell&gt;&lt;Data ss:Type="String"&gt;ABC&lt;/Data&gt;&lt;/ss:Cell&gt;
      &lt;ss:Cell&gt;&lt;Data ss:Type="String"&gt;10000&lt;/Data&gt;&lt;/ss:Cell&gt;
     &lt;/ss:Row&gt;
  &lt;/ss:Table&gt;
  </code></pre>
  
  <p></p>
  
  <h3>What I had tried </h3>
  
  <p>I tried to write simple xml with <code>DataTable.WriteXml()</code></p>
  
  <pre><code>System.IO.StringWriter writer = new System.IO.StringWriter();
  dt.WriteXml(writer, XmlWriteMode.WriteSchema, true);
  </code></pre>
  
  <p>But schema is different. I tried some loop through rows and columns of datatable. But stuck in that, Any help will be appriciated</p>
  
  <h3>Update 1</h3>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?mso-application progid="Excel.Sheet"?&gt;
  &lt;Workbook
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"&gt;
  
  &lt;Styles&gt;
   &lt;Style ss:ID="Default" ss:Name="Normal"&gt;
    &lt;Alignment ss:Vertical="Bottom"/&gt;
    &lt;Borders/&gt;
    &lt;Font/&gt;
    &lt;Interior/&gt;
    &lt;NumberFormat/&gt;
    &lt;Protection/&gt;
   &lt;/Style&gt;
   &lt;Style ss:ID="s27"&gt;
    &lt;Font x:Family="Swiss" ss:Color="#0000FF" ss:Bold="1"/&gt;
   &lt;/Style&gt;
   &lt;Style ss:ID="s21"&gt;
    &lt;NumberFormat ss:Format="yyyy\-mm\-dd"/&gt;
   &lt;/Style&gt;
   &lt;Style ss:ID="s22"&gt;
    &lt;NumberFormat ss:Format="yyyy\-mm\-dd\ hh:mm:ss"/&gt;
   &lt;/Style&gt;
   &lt;Style ss:ID="s23"&gt;
    &lt;NumberFormat ss:Format="hh:mm:ss"/&gt;
   &lt;/Style&gt;
  &lt;/Styles&gt;
  </code></pre>