B4J Question (solved)[JPOI] shiftRows with JO

Tayfur

Well-Known Member
Licensed User
Longtime User
Helle everbody;

I used Jpoi;
I generate code for rowshift for up lines

https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFSheet.html#method.summary

sample APACHE

I have an error like under below (no match ...)

But; 1 hour before. it was work.
I cant understant, My brain is stopded.

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Kitap As PoiWorkbook
    Private Sayfa As PoiSheet
    Private Satir1,Satir2,Satir2 As PoiRow
End Sub
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
 
    Kitap.InitializeExisting("C:\tempx","test.xlsx","")
    Kitap=SatirSil(Kitap,False)
 
 
    Try
        Kitap.Save("C:\tempx","test.xlsx")',"")'-----------------------
        'durum=Parca_YOLU&"\FIRMA.xlsx "&"DOSYA KULLANIMDA,TEKRAR DENEYİNİZ"
    Catch
        'durum=Parca_YOLU&"\FIRMA.xlsx "&"DOSYA KULLANIMDA,TEKRAR DENEYİNİZ" &CRLF&LastException
        Log (LastException)
    End Try
end sub

Private Sub SatirSil( wbook As PoiWorkbook,Kaydir As Boolean)    As PoiWorkbook
   Dim wsheet As PoiSheet=wbook.GetSheet(0)
 
    Dim jo As JavaObject = wsheet
    Dim builder As JavaObject
    jo.RunMethod("shiftRows", Array(5,6,-1))  ' this not works <<< only pozitif value works
    Return wbook
 
End Sub
java.lang.RuntimeException: Method: shiftRows not matched.


shiftRows
public void shiftRows(int startRow,
int endRow,
int n)
Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around. Calls shiftRows(startRow, endRow, n, false, false);
Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).

Specified by:
shiftRows in interface Sheet
Parameters:
startRow - the row to start shifting
endRow - the row to end shifting
n - the number of rows to shift
 

Attachments

  • test.zip
    5.9 KB · Views: 272
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But I want to shift upside. (but dont works.) I want to it.
you are overwriting 4... Maybe this is the problem... did you tried to move up to emtpy rows?

Or maybe you need to use real integers as values.
B4X:
dim fromrow, torow, noofrows as int
fromrow = 5
torow = 6
noofrows = -1
jo.RunMethod("shiftRows", Array(fromrow,torow,noofrows))
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
you are overwriting 4... Maybe this is the problem... did you tried to move up to emtpy rows?

Or maybe you need to use real integers as values.
B4X:
dim fromrow, torow, noofrows as int
fromrow = 5
torow = 6
noofrows = -1
jo.RunMethod("shiftRows", Array(fromrow,torow,noofrows))

Thank you @DonManfred

your chanced code is works.
as you say in your "use real integers as values"


Thank you very much.
 
Upvote 0
Top