B4J Question (solved)[JPOI] copyRows with Javaobject

Tayfur

Well-Known Member
Licensed User
Longtime User
B4X:
DosyaParca.InitializeExisting(DirApp,"tast.xlsx,"")
SayfaParca=DosyaParca.GetSheet(0)
Dim jo As JavaObject = SayfaParca
jo.RunMethod("copyRows", Array(3,4,5,1))



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

How can I use correct way wit JavaObject.
Thanks.
 

Tayfur

Well-Known Member
Licensed User
Longtime User
thank you boss..
I will try.
 
Last edited:
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User

B4X:
SayfaFirma=DosyaFirma.GetSheet(0)
        Dim jo As JavaObject = SayfaFirma
        Dim builder As JavaObject
        builder.InitializeNewInstance("org.apache.poi.ss.usermodel.CellCopyPolicy", Null)
        jo.RunMethod("copyRows", Array(3,4,5,builder.RunMethod("build", Null)))
I recived an error


Note: I use win 10 and Office2016
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User

Hello @Erel

I changed buldier ==>> createBuldier (if is it ok?)

B4X:
Dim jo As JavaObject = SayfaFirma
        Dim builder As JavaObject
        builder.InitializeNewInstance("org.apache.poi.ss.usermodel.CellCopyPolicy", Null)
        jo.RunMethod("copyRows", Array(3,5,25,builder.RunMethod("createBuilder", Null)))

bu I recivede en error


for helping example
B4X:
CellCopyPolicy policy = new CellCopyPolicy().createBuilder()
                                                  .cellFormula(false)
                                                  .cellStyle(true)
                                                  .cellValue(false)
                                                  .condenseRows(false)
                                                  .copyHyperlink(false)
                                                  .mergedRegions(false)
                                                  .mergeHyperlink(false)
                                                  .rowHeight(false)
                                                  .build();
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The correct code to create a CellCopyPolicy is
B4X:
Dim builder As JavaObject
builder.InitializeNewInstance("org.apache.poi.ss.usermodel.CellCopyPolicy.Builder", Null)
jo.RunMethod("copyRows", Array(3,4,5,builder.RunMethod("build", Null)))

However the problem is that the sheet you are using doesn't have a copyRows method: https://poi.apache.org/apidocs/org/apache/poi/xssf/streaming/SXSSFSheet.html
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User


I solved my way.
Look ti please; Maybe it is wrong way, but it works.
B4X:
#If JAVA
import org.apache.poi.ss.usermodel.CellCopyPolicy;
public static CellCopyPolicy Test() {
CellCopyPolicy policy = new CellCopyPolicy().createBuilder()
.build();
return policy;
}
#End If


Public Poicellpolicy As Object
    Public NativeMe As JavaObject
'//----------------------
     NativeMe = Me
    Poicellpolicy = NativeMe.RunMethod("Test", Null)
    Log(Poicellpolicy)
       SayfaFirma=DosyaFirma.GetSheet(0)
        Dim jo As JavaObject = SayfaFirma
        jo.RunMethod("copyRows", Array(3,5,25,Poicellpolicy))
            DosyaFirma.Save(file.dirapp,"myfile.xlsx")
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…