var fileName = Application.StartupPath + @"\Sample.xlsx"; var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties=Excel 12.0;",fileName); var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]",connectionString); var ds = new DataSet(); adapter.Fill(ds,"Sheet1"); DataTable data = ds.Tables["Sheet1"]; data.WriteXml(Application.StartupPath + @"\sample.xml");
</pre><pre class="csharp" name="code">
——————————————————————————————————————————————————————————————————
欢迎大神光临菜鸟博客,希望能得到各位大神在编码方面的指引,同时欢迎与我一样刚进入编程世界的朋友一起讨论学习!相信前进的道路上,有你们,编程世界会更加精彩!