Advertisement
Advertisement
| 06.17.2008 at 05:43AM PDT, ID: 23491224 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: |
Imports System.Reflection
Imports System.IO
Imports <xmlns="urn:schemas-microsoft-com:office:spreadsheet">
Imports <xmlns:o="urn:schemas-microsoft-com:office:office">
Imports <xmlns:x="urn:schemas-microsoft-com:office:excel">
Imports <xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
Imports <xmlns:html="http://www.w3.org/TR/REC-html40">
Public Class DoXml
Sub ProcessXMLFile
Try
Dim sheet As XDocument = XDocument.Load(fname)
'This works
For Each R In sheet...<Row>
Debug.Print(R.<Cell>(0).Value)
Debug.Print(R.<Cell>(1).Value)
Debug.Print(R.<Cell>(2).Value)
Next
'This returns nullexception error
Dim y = From d In sheet...<Row> _
Let Source = d.<cell>(0) _
Let SubSys = d.<Cell>(1) _
Select _
Source = Source.Value, _
SubSys = SubSys.Value _
Skip (1)
For Each x In y
iRowcount = iRowcount + 1
Console.WriteLine("processing row: " & iRowcount & " : " & x.ToString)
Next
Catch ex As NullReferenceException
'do nothing except report back
console.writeline(vbTab & "No Records to load in " & FuncName)
Catch ex As Exception
Console.writeline(vbTab & "Error in LoadDespatchesXML: " & ex.Message)
End Try
End Sub
End Class
|