txtErrors.Text="":txtErrors.visible=False
HdrList.Initialize
HdrList.AddAll(Array As String("Surname" , "GivenName" , "Age" , "BirthDate", "PlaceOfBirth" , "DeathDate" , "BurialDate" , "CremationDate" , "BurialPlaceOrCremation" , "PlaceOfDeath" , "Occupation" , "RegNumber" , "Transcription" , "Comments" ))
Dim fc As FileChooser ' Use filechooser from jFX library
Dim fileSelected As String ' File selected. If selected full path is returned else ""
Dim n,p As String
fc.Initialize
fc.InitialDirectory = GetSystemProperty("user.home", "c:\") ' Set starting folder
fc.Title = "Select an Excel File..."
fc.SetExtensionFilter("Excel files..",Array As String("*.xls","*.xlsx"))
fileSelected = fc.ShowOpen(MainForm) ' Show the dialog and select
'Return fileSelected
Dim fileO As JavaObject
fileO.InitializeNewInstance("java.io.File", Array As Object(fileSelected))
Dim n As String = fileO.RunMethod("getName",Null)
Dim p As String = fileO.RunMethod("getPath", Null)
p = p.Replace(n, "")
poi.InitializeExisting(p,n,"",False)
sheet=poi.GetSheet(0)
Dim lst1 As List
lst1.Initialize
lst1.AddAll(sheet.GetRow(0).Cells)
For i = 0 To lst1.Size - 2
Dim pc As PoiCell = lst1.Get(i)
Dim s As String = HdrList.Get(i)
Log(pc&" "& s)
If pc.Value <> s Then
Dim x As Int=i+1
fx.Msgbox2(Null, "Column " & x &" header name is " & pc.Value & " but should be " & s &". Please correct the File and try again.","Column Name Error" ,"OK","","",fx.MSGBOX_WARNING)
Return
End If
Next
'get the number of rows
LastRow=sheet.LastRowNumber
rows=LastRow
txtFilePath.Text=p:txtFile.text=n
fx.Msgbox(Null,"Column headers are correct." & CRLF & "There are " & rows & " rows ready for import","File Ready" )
End Sub