B4J Question POI use newer 3.16 or 3.17 version

Robert Valentino

Well-Known Member
Licensed User
Longtime User
How can I upgrade to using POI 3.16

I have a spread sheet that has 779 rows in it and when I run the following code:

B4X:
       Dim  JO       As JavaObject   = Sheet
       Dim  LastRow   As Int       = Sheet.LastRowNumber
       Dim  RowNum     As Int
       
       Dim  Cmp1     As String
       Dim  Cmp2     As String
       
       Dim  Row     As PoiRow
       Dim  Row2     As PoiRow
       
       Log("Sort Sheet:" &Sheet.Name)
       
       
       For RowNum = 0 To LastRow-1
         Row    = Sheet.GetRow(RowNum)
         
         If  Row.IsInitialized = False Then Continue
           
         Cmp1 = Row.GetCell(ColumnToSort).ValueString
           
         Log("RowNum:" &RowNum &"  Cmp1:" &Cmp1)         
       Next

I do not get a Valid row until I get to row 679 and clearly the rows are there when I open the spreadsheet in excel. But even after I find a valid row and compare it to another later on and try to do a shiftrows
B4X:
#Region ShiftRows
Public  Sub ShiftRows(Sheet As PoiSheet, StartRow As Int, EndRow As Int, DirectionAmt As Int)
   
       Dim jo As JavaObject = Sheet
   
       jo.RunMethod("shiftRows", Array(StartRow, EndRow, DirectionAmt))     
End Sub
#end Region

I try the shift routine and get this
B4X:
          Log("RowNum:" &RowNum &"  Cmp1:" &Cmp1 &"  Cmp2:" &Cmp2)
           
           If  Cmp2.CompareTo(Cmp1) < 0 Then
             ShiftRows(Sheet, Row2.RowNumber, Row2.RowNumber, -1)
             ShiftRows(Sheet, Row.RowNumber,    Row.RowNumber,    1)
             
             Sorting = True
           End If


RowNum:768  Cmp1:World�s Finest Comics  Cmp2:Worlds Collide
Error occurred on line: 135
java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

There are reports of shiftrows using minus 1 not working right in earlier versions (the version we are using).

Maybe this is the problem but I would like to get to the current release. Is there an easy way to do this?

Thanks

BobVal
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…