VB.Net-Informations.com
   Home      .Net Framework      VB.NET      C#                                                                      About


  How to create an XML file from Excel

XML is a general purpose tag based language and very easy to transfer and store data across applications. The .Net Framework provides the Classes for read, write, and other operations in XML formatted files .

The following program shows how to create an XML file from an Excel file content . Here we are using an OleDbConnection to read the excel file and store the content to a Dataset . Call the method WriteXml of Datset to write to the XML file.

         VB.NET Source Code Download           Print Source Code
         How to create an XML file from Excel - Download
        
C# Tutorial

Imports System.Data
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim MyConnection As System.Data.OleDb.OleDbConnection
            Dim ds As System.Data.DataSet
            Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
            MyConnection = New System.Data.OleDb.OleDbConnection _
            ("provider=Microsoft.Jet.OLEDB.4.0;Data Source='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 ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

Click here to download the input excel file xl2xml.xls

VB.NET XML Related Contents
*     How to XML in VB.NET
*     How to create an XML file in VB.NET
*     How to open and read an XML file in VB.NET
*     How to create an XML file in VB.NET using Dataset
*     How to open and read an XML file in VB.NET using Dataset
*     How to create an XML file from SQL in VB.NET
*     How to search in an XML file
*     How to filter data in an XML file
*     How to insert data from xml to database
*     How to create an Excel file from XML
*     How to xml to DataGridView
*     How to create a TreevView from XML
*     How to create Crystal Reports from XML
*     How to serialization in xml
*     How to serialize a .Net Object to XML
*     How to de-serialize from an XML file to .Net Object


   Home      VB.NET      C#
VB.Net Related Topics
*     Microsoft .Net Framework Tutorials
*     VB.NET Language Basics Tutorials
*     VB.NET Program Flow Control Tutorials
*     VB.NET Collections Tutorials
*     VB.NET String Tutorials
*     VB.NET Files Tutorials
*     VB.NET Excel 2007 Tutorials
*     VB.NET Crystal Reports Tutorials
*     VB.NET Communications Tutorial
*     VB.NET ADO.NET Tutorial
*     ADO.NET Data Providers help and Tutorial
*     VB.NET ADO.NET Dataset Tutorial
*     ADO.NET DataAdapter and Dataset
*     VB.NET ADO.NET DataView Tutorial
*     VB.NET Remoting Tutorial
*     VB.NET XML Tutorial
*     VB.NET DataGridView Tutorial
   Home      VB.NET      C#
More Source Code :   
Mail to :  feedback@net-informations.com
  |  Home   |  VB.NET   |  C#   |  SiteMap   |  Terms of Use   |  About   |
net-informations.com (C) 2010
All Rights Reserved. All other trademarks are property of their respective owners.