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
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