Losing CellTypes after RecalculateAll

Posted by: Bryan.Graves on 6 June 2019, 11:18 am EST

    • Post Options:
    • Link

    Posted 6 June 2019, 11:18 am EST

    We are upgrading our spread to the newest version. A problem we are experiencing is with SheetView.RecalculateAll. When you call this method to force the formulas to recalculate, it removes all celltypes that have been set earlier on the spread.

    Is this a known issue?

    To recreate for yourself, create a Form with a FpSpread(12.45.20191.0) and Button and insert the following code.

    When the button is clicked, the Combobox disappears as well as the currency formats.

    
    Public Class Form1
       Private WithEvents BindingSource As New BindingSource
       Private CurrencyCellType As New FarPoint.Win.Spread.CellType.CurrencyCellType
       Private ComboboxCellType As New FarPoint.Win.Spread.CellType.ComboBoxCellType
       Private Tests As New List(Of TestClass)
    
       Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
          LoadForm()
       End Sub
    
       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          'MsgBox(String.Format("FpSpread1_Sheet1.Columns(0).CellType = ComboboxCellType is {0}{1}FpSpread1_Sheet1.Columns(1).CellType = CurrencyCellType is {0}", FpSpread1_Sheet1.Columns(0).CellType Is ComboboxCellType, vbCrLf, FpSpread1_Sheet1.Columns(0).CellType Is CurrencyCellType))
          FpSpread1_Sheet1.RecalculateAll()
          'MsgBox(String.Format("FpSpread1_Sheet1.Columns(0).CellType = ComboboxCellType is {0}{1}FpSpread1_Sheet1.Columns(1).CellType = CurrencyCellType is {0}", FpSpread1_Sheet1.Columns(0).CellType Is ComboboxCellType, vbCrLf, FpSpread1_Sheet1.Columns(0).CellType Is CurrencyCellType))
       End Sub
    
       Private Sub LoadForm()
          Tests.Add(New TestClass(1, 201.2))
          Tests.Add(New TestClass(2, 10.7))
          Tests.Add(New TestClass(3, 25.9))
          BindingSource.DataSource = Tests
    
          CurrencyCellType.DecimalPlaces = 0
          CurrencyCellType.Separator = ","
          CurrencyCellType.ShowSeparator = True
          CurrencyCellType.ShowCurrencySymbol = True
          ComboboxCellType.Items = New String() {1, 2, 3}
    
          FpSpread1.Sheets(0).ColumnCount = 2
          FpSpread1.Sheets(0).DataSource = BindingSource
    
          FpSpread1_Sheet1.Columns(0).DataField = "Units"
          FpSpread1_Sheet1.Columns(1).DataField = "Dollars"
          FpSpread1_Sheet1.Columns(0).CellType = ComboboxCellType
          FpSpread1_Sheet1.Columns(1).CellType = CurrencyCellType
       End Sub
    
       Public Class TestClass
          Private mUnits As Integer
          Private mDollars As Decimal
    
          Public Property Units As Integer
             Get
                Return mUnits
             End Get
             Set(value As Integer)
                mUnits = value
             End Set
          End Property
    
          Public Property Dollars As Decimal
             Get
                Return mDollars
             End Get
             Set(value As Decimal)
                mDollars = value
             End Set
          End Property
    
          Sub New(ByVal units As Integer, ByVal dollars As Decimal)
             Me.Units = units
             Me.Dollars = dollars
          End Sub
       End Class
    End Class
    
    
  • Posted 7 June 2019, 10:07 am EST

    Hi Bryan,

    Thank you for sharing the code.

    This is not an issue. To make it work correctly, just set DataAutoCellTypes property to False.```

    FpSpread1.Sheets(0).DataAutoCellTypes = False

    Hopefully it should get the issue resolved for you.
    
    Warm Regards,
    Ruchir
  • Posted 7 June 2019, 4:49 pm EST

    It did. Thanks

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels