I have a pdf form containing 6 rows of radiobuttons and 1 text field on submit it gives me this xml file:
<?xml version="1.0" encoding="UTF-8"?>
<form1
><Table1
><HeaderRow xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/><Row1 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/><Row2 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/><Row3 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/><Row4 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/><Row5 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/></Table1
><Table2
><Row1 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/></Table2
><Table3
><Row1 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/><Row1 xmlns:xfa="http://ift.tt/1c7vSVL" xfa:dataNode="dataGroup"
/></Table3
><QualityWork
>1</QualityWork
><Ontime
>2</Ontime
><QualityReport
>3</QualityReport
><Needs
>4</Needs
><Comm
>5</Comm
><Global
>6</Global
><Comments
>This is a comment</Comments
></form1
>
I'm trying to create a vb.net program that will create an excel sheet with the data from the xml file.
I tried using this vb.net code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filePath = create_xml.Text()
Dim m_xmld As XmlDocument
'Create the XML Reader
m_xmld = New XmlDocument()
m_xmld.Load(filePath)
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
m_nodelist = m_xmld.SelectNodes("/form1")
Dim total_untokenized = ""
For Each m_node In m_nodelist
total_untokenized = m_node.ChildNodes.Item(0).InnerText
comments = m_node.ChildNodes.Item(1).InnerText
Next
Dim total_tokenized As Integer
total_tokenized = 0
For i = 1 To 6
total_tokenized = total_tokenized + Strings.Mid(total_untokenized, i, 1)
Next
Dim total_col = 7
Dim MyArrayList = New ArrayList(total_col)
MyArrayList.Add(comments)
For i = 1 To 6
MyArrayList.Add(Strings.Mid(total_untokenized, i, 1))
Next
MyArrayList.Add(total_tokenized)
Dim MyArrayList2 = New ArrayList(total_col)
MyArrayList2.Add("QualityWork")
MyArrayList2.Add("Ontime")
MyArrayList2.Add("QualityReport")
MyArrayList2.Add("Needs")
MyArrayList2.Add("Comm")
MyArrayList2.Add("Global")
MyArrayList2.Add("Comments")
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
For col = 0 To total_col - 1
oSheet.Cells(1, col + 1) = MyArrayList2.Item(col)
Next
oSheet.Rows("1:1").Font.Bold = True
For col = 0 To total_col - 1
oSheet.Cells(2, col + 1) = MyArrayList.Item(col)
Next
End Sub
But this m_nodelist = m_xmld.SelectNodes("/form1")
seems to stay empty, I always get an error at this line MyArrayList.Add(Strings.Mid(total_untokenized, i, 1))
Do I have to change the design of my form or it's only a error in vb?
Aucun commentaire:
Enregistrer un commentaire