using System; using System.Data; using System.Windows.Forms; using System.Xml; using System.Data; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { System.Data.OleDb.OleDbConnection MyConnection ; System.Data.DataSet ds ; System.Data.OleDb.OleDbDataAdapter MyCommand ; MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='Specify path here \\xl2xml.xls';Extended Properties=Excel 8.0;"); MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection); MyCommand.TableMappings.Add("Table", "Product"); ds = new System.Data.DataSet(); MyCommand.Fill(ds); MyConnection.Close(); ds.WriteXml("Product.xml"); } catch (Exception ex) { MessageBox.Show (ex.ToString()); } } } }