B4J Question jPOI: How do I return the CellType and Refresh RC Formular?

Mashiane

Expert
Licensed User
Longtime User
Hi there

I'm using a template xlsx file to generate my report which has built in formulars and built in sparklines. I'm able to set the cell data and this works well. The last row in the sheet has formulars, but they dont recalculate themselves.

I saw this example and figured out that I could refresh the cell content formular. Thing is it does not refresh.

B4X:
If hasFormula = True Then
        'we have formulars
        Dim lastRow As Int = ws.LastRowNumber - 1
        'get the last row
        wsrow = ws.GetRow(lastRow)
        wsrow.IsInitialized
        For cellCnt = startCell To endCell
            Select Case cellCnt
            Case 1,2,3,4,5,6,7,8,9,10,11,12
                'get the cell in question
                wsCell = wsrow.GetCell(cellCnt)
                wsCell.IsInitialized
                wsCell.ValueFormula = wsCell.ValueFormula
            End Select
        Next
    End If

I want to bypass the cellCnt counter of 1 to 12 and just detect the cellType and then apply the formula thats already existing in that RC location.

Trying this says the object is not initialized..

B4X:
If wsCell.CellType = wsCell.TYPE_FORMULA Then
                    wsCell.ValueFormula = wsCell.ValueFormula
                End If

Thanks in advance?
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Thanks @Erel, I dont know what I missed but the refresh works. The issue is Getting the CellType using that method in a cell. How does one use that method in the code? I want to detect that and execute some code.

CellType.jpg
 
Upvote 0
Top