title: Convert Excel to XML with C#
body: <p>I tried to convert excel file to XML file. And I did it successfully. However when I run the APP on another PC (where I dont have SQL server manager), it is not working anymore. I receive this error</p>
  <blockquote>
  <p>'Microsoft.ACE.OLEDB.16.0' provider is not registered on the local machine</p>
  </blockquote>
  <p>which I tried to solve with every solved question here (installing Microsoft Access Database Engine 2016 Redistributable, converting app into x86, etc...) and nothing worked.</p>
  <p>But since I don't really need (or at least I think so) Access, is there any other way, how to convert excel file to xml?</p>
  <p>Here is to code</p>
  <pre class="lang-cs prettyprint-override"><code>XmlDocument doc = new XmlDocument();
  
  try
  {               
      bool test = Environment.Is64BitProcess;
      FileName.Content = filelocation.Substring(filelocation.LastIndexOf(@&quot;\&quot;)+1);
  
      if (!test)
      {
          connStr = &quot;Provider=Microsoft.ACE.OLEDB.16.0;Data Source=&quot; + filelocation + &quot;;Extended Properties=\&quot;Excel 12.0;HDR=Yes;IMEX=2\&quot;&quot;;                    
      }               
  
      OleDbConnection conn = new OleDbConnection(connStr);
      OleDbCommand cmd = new OleDbCommand();
      cmd.Connection = conn;
      OleDbDataAdapter da = new OleDbDataAdapter(cmd);
      DataTable dt = new DataTable();
  </code></pre>
  <p>To here it is working, here is the issue</p>
  <pre class="lang-cs prettyprint-override"><code>    conn.Open();
      DataTable dtSheet = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
      string sheetName = dtSheet.Rows[0][&quot;table_name&quot;].ToString();
      cmd.CommandText = &quot;select * from [&quot; + sheetName + &quot;]&quot;;
      da.SelectCommand = cmd;
      da.Fill(dt);
      conn.Close();
  </code></pre>
  <p>And then I continue...</p>
  <pre class="lang-cs prettyprint-override"><code>    DataSet ds = new DataSet();                
      ds.Tables.Add(dt);                
      oItem = dt.Rows.Count;
      oItem -= 1;
  
      XmlDeclaration declaire = doc.CreateXmlDeclaration(&quot;1.0&quot;, &quot;utf-8&quot;, null);
      declaire.Standalone = &quot;yes&quot;;                
      XmlElement rootnode = doc.CreateElement(&quot;Wiring&quot;);                    
      doc.InsertBefore(declaire, doc.DocumentElement);
      doc.AppendChild(rootnode);                
  
      while (i &lt;= oItem)
      {
          XmlElement dobEle = doc.CreateElement(&quot;Machine&quot;);
  
          do
          {...
  </code></pre>
  <p>Is there any other way how to solve the problematic code?</p>
  <p><strong>EDIT</strong>
  I have installed Office on both PCs. And I have tried .Ace.OLEDB.x (4-23 [just to be sure]) and on PC where I develop the APP v.12 and v.16 works. On the PC where I deployed the app none of them works</p>
  <p><strong>Edit 2</strong> So I just found out I have office 365 on the 2nd computer but not fully licensed Access (for whatever reason). Could someone confirm, if that's the reason why it doesn't work?</p>