Why is this code throwing this error?
Thanx in advance,
Mark Stuart
Edit: adding full error log:
B4X:
Private Sub lvSheets_SelectedIndexChanged(Index As Int)
Dim filename As String = txtFilename.Text
If File.Exists("", filename) Then
Dim sheetname As String = lvSheets.Items.Get(Index)
'get sheet data
XL.Initialize
Dim result As XLReaderResult = XL.Reader.ReadRange("", filename, sheetname & "!A3:F100") '<<==== error thrown here
result.LogResult(True)
'set table column names
tbSheetData.AddColumn(result.Get(XL.AddressName("A2")), tbSheetData.COLUMN_TYPE_TEXT)
tbSheetData.AddColumn(result.Get(XL.AddressName("B2")), tbSheetData.COLUMN_TYPE_TEXT)
tbSheetData.AddColumn(result.Get(XL.AddressName("C2")), tbSheetData.COLUMN_TYPE_TEXT)
tbSheetData.AddColumn(result.Get(XL.AddressName("D2")), tbSheetData.COLUMN_TYPE_TEXT)
tbSheetData.AddColumn(result.Get(XL.AddressName("E2")), tbSheetData.COLUMN_TYPE_TEXT)
tbSheetData.AddColumn(result.Get(XL.AddressName("F2")), tbSheetData.COLUMN_TYPE_TEXT)
Else
xui.MsgboxAsync("File not found!", "Error")
End If
End Sub
Thanx in advance,
Mark Stuart
Edit: adding full error log:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 23 (XLReader)
java.io.FileNotFoundException: \C:\Projects\B4J\XLS_Read_Approval_Levels\Approval Levels.xlsx
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:268)
at anywheresoftware.b4j.objects.PoiWorkbookWrapper.InitializeExisting(PoiWorkbookWrapper.java:78)
at b4j.example.xlreader._openworkbook(xlreader.java:328)
at b4j.example.xlreader._readranges(xlreader.java:563)
at b4j.example.xlreader._readrange(xlreader.java:56)
at b4j.example.main._lvsheets_selectedindexchanged(main.java:173)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:233)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:185)
at java.lang.Thread.run(Thread.java:748)
Last edited: