Android Question jxl setAutoSize is not working

Mostez

Well-Known Member
Licensed User
Longtime User
Based on this example,

I applied the example as it is, but the code editor marked this line in red and reported this message:
clsSysTools - 286: Unknown member: runmethod
B4X:
Dim jcell As JavaObject = sheet1.RunMethod("getColumnView", Array(ColumnIndex))

I modified the code to this, but at run time I get this error:
java.lang.RuntimeException: Method: setAutoSize not found in: jxl.CellView

B4X:
For i = 0 To Table.Columns.Size - 1
            Dim c As B4XTableColumn = Table.Columns.Get(i)
            Dim Cn As String = c.Title
            Dim cell As WritableCell
            cell.InitializeText(i, 0, Cn)
            cell.SetCellFormat(cellFormat)
            sheet1.AddCell(cell)
            'sheet1.SetColumnWidth(i, 15)

            Dim jsheet As JavaObject = sheet1
            Dim jcell As JavaObject = jsheet.RunMethod("getColumnView", Array(i))'= sheet1.RunMethod("getColumnView", Array(i))
            jcell.RunMethod("setAutoSize", Array(True))
            jsheet.RunMethod("setColumnView", Array(i, jcell))
        Next

Any ideas hot to fix this?
 

Mostez

Well-Known Member
Licensed User
Longtime User
Thanks Erel
EDIT: sorry, but I tried the code and I've got this error as in screenshot
Image3.jpg
 
Last edited:
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
Finally I got it :)
it should be 'setAutosize' not 'setAutoSize' as found in CellView.java source file, here is the final code
Thanks so much Erel, your jxl example saved me a lot of work

B4X:
Dim jsheet As JavaObject = sheet1
Dim jcell As JavaObject
jcell = jsheet.RunMethod("getColumnView", Array(i))
jcell.RunMethod("setAutosize", Array(True))
jsheet.RunMethod("setColumnView", Array(i, jcell))
 
Upvote 0
Top