B4J Question [SOLVED] jPOI how to return 'value' in formular cell?

Mashiane

Expert
Licensed User
Longtime User
Hi

SOLUTION: https://www.b4x.com/android/forum/t...ls-text-property-display-value.99907/#content

I have a large worksheet with a lot of columns that have formulas. I want to read the worksheet and save the values to a database. I am able to read the rest of the data however the formulas are returned as is.

How can I ensure that when ...

1. Open the workbook, all formulars are updated?
2. Then when I read a cell, the value/result of the formular is returned and not the formular?



This is what I'm testing

B4X:
'return the cell value
Sub PoiGetCell(cell As PoiCell, bFormulasAsValues As Boolean) As String
    If cell.IsInitialized = True Then
        Select Case cell.CellType
            Case cell.TYPE_NUMERIC
                Return cell.ValueNumeric
            Case cell.TYPE_STRING
                Return cell.ValueString
            Case cell.TYPE_FORMULA
                If bFormulasAsValues = False Then
                    Return cell.ValueFormula
                Else
                    Return cell.Value
                End If
            Case cell.TYPE_BLANK
                Return ""
            Case cell.TYPE_BOOLEAN
                Return cell.ValueBoolean
            Case cell.TYPE_ERROR
                Return ""
            Case Else
                Return cell.Value
        End Select
    Else
        Return ""
    End If
End Sub

Thanks..
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…