Formula problem in V11 with complex sheet

Posted by: tosch on 8 October 2018, 8:31 pm EST

    • Post Options:
    • Link

    Posted 8 October 2018, 8:31 pm EST

    We had to upgrade spread from V10 to V11 because of a cursor problem.

    Now I’m facing an even bigger problem in a planning tool we have.

    Please load the attached Yearplan.xml into the Spread Designer.

    In cell F9 you can enter the number of hours for all days in the year from monday to friday. When you change the number to 123 not all the cells get recalculated properly. On my machine I enter 123 and the cells in month Juni/Juli/September/Dezember are not updated.

    When I change the year in cell J1, all days are recalculated properly.

    I have checked all the formulas in all cells, they are ok and this application ran fine with V10.

    There are other errors in the ‘Wo’ columns. Those formulas contain custom formulas an can obviously not be recalculated in the designer.

    Thomas

    YearPlan.zip

  • Posted 11 October 2018, 1:20 am EST

    Hi Thomas,

    I opened your XML file with Spread in code and with Spread Designer and found that cell F9 is not editable.

    After I unlocked the cell I could observe the formula being updated after changing the year in Cell J1. It seems there are lot inter-dependent formulas in the sheet.

    Could you please let me know the source of the file, how did you create this XML file. Also which language settings you have on your machine?

    Thanks,

    Deepak Sharma

  • Posted 11 October 2018, 4:45 pm EST

    Deepak,

    I’m sorry there is a typo in my first message. the cell you’re supposed to change is F3.

    In F3 you can enter the number of hours for all weekdays monday-thursday, F4 is for all fridays.

    I created this in spread designer.

    The language settings are set to German/Swiss.

    Thomas

  • Posted 14 October 2018, 8:51 pm EST

    Hello,

    I have escalated this issue to our development team as a bug. I will let you know as soon as I get an update on this. The bug id for this issue is 265701.

    Thanks,

    Deepak Sharma

  • Posted 15 October 2018, 7:55 pm EST

    Hi Thomas,

    Developers observed that you have used a custom function ‘WeekOfYear’ in XML, could you please share the implementation of this custom function with us?

    Thanks,

    Deepak Sharma

  • Posted 15 October 2018, 9:58 pm EST

    Deepak,

    here is the code. There is also a ‘Easter’ function.

    
    Public Class WeekOfYearFunctionInfo
        Inherits FarPoint.CalcEngine.FunctionInfo
    
        Sub New()
    
        End Sub
        Public Overrides ReadOnly Property Name() As String
            Get
                Return "WeekOfYear"
            End Get
        End Property
    
        Public Overrides ReadOnly Property MinArgs() As Integer
            Get
                Return 1
            End Get
        End Property
    
        Public Overrides ReadOnly Property MaxArgs() As Integer
            Get
                Return 1
            End Get
        End Property
    
        Public Overrides Function Evaluate(ByVal args() As Object) As Object
            Dim num As Integer = FarPoint.CalcEngine.CalcConvert.ToInt(args(0))
            Return GetIso8601WeekOfYear(System.DateTime.FromOADate(num))
        End Function
    
    End Class
    
        Public Function GetIso8601WeekOfYear(ByVal xtime As DateTime) As Integer
            Dim day As DayOfWeek = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(xtime)
            If (day >= System.DayOfWeek.Monday And day <= System.DayOfWeek.Wednesday) Then
                xtime = xtime.AddDays(3)
            End If
    
            '// Return the week of our adjusted day
            Return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(xtime, CalendarWeekRule.FirstFourDayWeek, System.DayOfWeek.Monday)
        End Function
    
    
    Public Class EasterFunction
        Inherits FarPoint.CalcEngine.FunctionInfo
    
        Public Overrides ReadOnly Property Name() As String
            Get
                Return "Easter"
            End Get
        End Property
    
        Public Overrides ReadOnly Property MinArgs() As Integer
            Get
                Return 1
            End Get
        End Property
    
        Public Overrides ReadOnly Property MaxArgs() As Integer
            Get
                Return 1
            End Get
        End Property
    
        Public Overrides Function Evaluate(ByVal args() As Object) As Object
            'Gauss's algorithm
            'This algorithm for calculating the date of Easter Sunday was first presented by the mathematician 
            'Carl Friedrich Gauss.
    
            'The number of the year is denoted by Y; mod denotes the remainder of integer division 
            '(e.g. 13 mod 5 = 3; see modular arithmetic). Calculate first a, b and c:
    
            '        A = y Mod 19
            '        B = y Mod 4
            '        C = y Mod 7
            'Then calculate
    
            'd = (19a + M) mod 30 
            'e = (2b + 4c + 6d + N) mod 7 
            'For the Julian calendar (used in eastern churches) M = 15 and N = 6, 
            'and for the Gregorian calendar (used in western churches) M and N are from the following table:
    
            '  Years     M   N
            '1583-1699  22   2
            '1700-1799  23   3
            '1800-1899  23   4
            '1900-2099  24   5
            '2100-2199  24   6
            '2200-2299  25   0
            'If d + e < 10 then Easter is on the (d + e + 22)th of March, and is otherwise on the (d + e - 9)th of April.
    
            'The following exceptions must be taken into account:
    
            'If the date given by the formula is the 26th of April, Easter is on the 19th of April. 
            'If the date given by the formula is the 25th of April, with d = 28, e = 6,and a > 10, Easter is on the 18th of April. 
    
            Dim l As Integer = args.Length
    
            Dim lookupValue As String = args(0).ToString()
             Try
                Dim lv As FarPoint.CalcEngine.CalcReference = args(0)
                lookupValue = lv.GetValue(lv.Row, lv.Column)
            Catch
                lookupValue = args(0).ToString()
            End Try
    
            Dim A, B, C, D, e, TagesZahl As Integer
            Dim Jahreszahl As Integer = CInt(lookupValue)
    
            A = Jahreszahl Mod 19
            B = Jahreszahl Mod 4
            C = Jahreszahl Mod 7
            D = (19 * A + 24) Mod 30
            e = (2 * B + 4 * C + 6 * D + 5) Mod 7
            TagesZahl = 22 + D + e
            If TagesZahl > 31 Then
                TagesZahl = TagesZahl - 31
                If TagesZahl = 26 Then TagesZahl = 19
                If (TagesZahl = 25 And D = 28 And A > 10) Then TagesZahl = 18
                Return CDate(TagesZahl.ToString + ".04." + Jahreszahl.ToString) ' DateSerial(JahresZahl,  4, TagesZahl)
            Else
                Return CDate(TagesZahl.ToString + ".03." + Jahreszahl.ToString) ' DateSerial(JahresZahl,  3, TagesZahl)
            End If
    
            Return 0 'FarPoint.CalcEngine.CalcError.NotAvailable
        End Function
    
        Public Overrides Function AcceptsReference(ByVal i As Integer) As Boolean
            Return True
        End Function
    End Class
    
    
    
    
  • Posted 17 October 2018, 1:22 am EST

    Hello,

    Thank you for providing us the code. We will further check it and get back to you soon.

    Thanks,

    Deepak Sharma

  • Posted 25 October 2018, 12:47 am EST

    Hello,

    It has been been identified as a bug of Spread and will be fixed in next service pack of Spread .NET v11 which is scheduled to be released next month.

    Thanks,

    Deepak Sharma

  • Posted 23 June 2019, 7:41 pm EST

    Hello,

    This issue has been fixed in our latest version of Spread .NET v12. Please download the same from our website and check.

    Thanks,

    Deepak Sharma

Need extra support?

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

Learn More

Forum Channels