VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



create excel file from xml file

by tanakorn wichaiwong (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 28th June 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

create excel file from xml file

API Declarations


Imports Microsoft.Office.Interop

Rate create excel file from xml file



            Dim xml As New XmlDocument
            xml.Load("C:\bcptable.xml")
            Dim node As XmlNode
            Dim list As XmlNodeList
            list = xml.SelectNodes("//General")

            Dim app As New Microsoft.Office.Interop.Excel.Application
            Dim exbook As Microsoft.Office.Interop.Excel.Workbook
            Dim exsheet As Microsoft.Office.Interop.Excel.Worksheet
            exbook = app.Workbooks.Add
            exsheet = exbook.Sheets(1)
            Dim xx As Integer
            For Each node In list
                xx += 1
                exsheet.Cells(xx, 1) = node.Attributes("File").Value
                exsheet.Cells(xx, 2) = node.Attributes("Table").Value
            Next
            exbook.SaveAs("C:\took1.xls")
            app.Visible = True

            MsgBox("complete")
            Exit Sub
        Catch ex As Exception
            MsgBox(ex.ToString)
        End

Download this snippet    Add to My Saved Code

create excel file from xml file Comments

No comments have been posted about create excel file from xml file. Why not be the first to post a comment about create excel file from xml file.

Post your comment

Subject:
Message:
0/1000 characters