B4J Question Fetching/Getting row number in Excel table

GMan

Well-Known Member
Licensed User
Longtime User
I have a online Excel form that i called from a webview.
Now i simply want to get the number of the row (the very left column contains that, see screenshot)

Or - if that is not possible- how can i get the choosen rownumber into my code ?
 

Attachments

  • ExcelListe.png
    ExcelListe.png
    2.3 KB · Views: 191

GMan

Well-Known Member
Licensed User
Longtime User
Thx Erel,
then it should be easier to load the XLS-File into a listview - some Tut about that ?
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Using poi


B4X:
  Dim TempWB As PoiWorkbook
   
   TempWB.InitializeExisting("E:\", "Test.xlsx", "")
   
   If  TempWB.NumberOfSheets > 0 Then
       Dim Sheet      As PoiSheet    = TempWB.GetSheet(0)    '  Get the first sheet
     
       Log("Sheet:" &Sheet.Name)                                      ' Show sheet name
       Log("Rows:" &SheetPhysicalRows(Sheet)                     ' get the number of physical rows              -  I believe this is the number you want

       Dim Row      As PoiRow      = Sheet.GetRow(SheetPhysicalRows(Sheet) - 1)
       Dim Cell      As PoiCell     = Row.GetCell(0)
     
       Dim CellValue    As String   = Cell.ValueString               ' this will give you the first column of the last row
   End If

Routine SheetPhysicalRows

B4X:
#Region SheetPhysicalRows
Public  Sub SheetPhysicalRows(Sheet As PoiSheet) As Int
       Dim jo As JavaObject = Sheet
   
       Return jo.RunMethod("getPhysicalNumberOfRows",Null)   
End Sub
#end Region
 
Upvote 0
Top