Spread ASP.NET 18
Spread for ASP.NET 18 Product Documentation / Developer's Guide / Managing Formulas / Setting Calculation Culture
In This Topic
    Setting Calculation Culture
    In This Topic

    In Spread ASP.NET, the calculation culture for the FpSpread instance can be set by using CalculationCulture property. It displays the calculation results in the specified culture, which can differ from the main culture value, set by using Thread.CurrentCulture.

    The following example shows how to set the thread culture and calculation culture to different values.

    C#
    Copy Code
    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL");// Dutch
        FpSpread1.CalculationCulture = new CultureInfo("de-DE");// German
        if (!IsPostBack)
        {
            DateTime dateValue = DateTime.Now.Date;
            FpSpread1.Sheets[0].Columns[0].Width = 200;
            FpSpread1.Sheets[0].Columns[1].Width = 250;
            FpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "Dates";
            FpSpread1.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Days Of Week in German";
            // This formula evaluates in Dutch but displays Day for a specific date in German culture 
            //because CalculationCulture is set to German
    
            FpSpread1.Cells[0, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue + " \"),\"dddd\")";
            FpSpread1.Cells[1, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue.AddDays(1) + " \"),\"dddd\")";
            FpSpread1.Cells[2, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue.AddDays(2) + " \"),\"dddd\")";
            FpSpread1.Cells[3, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue.AddDays(3) + " \"),\"dddd\")";
            FpSpread1.Cells[4, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue.AddDays(4) + " \"),\"dddd\")";
            FpSpread1.Cells[5, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue.AddDays(5) + " \"),\"dddd\")";
            FpSpread1.Cells[6, 1].Formula = "TEXT(DATEVALUE(\"" + dateValue.AddDays(6) + " \"),\"dddd\")";
            FpSpread1.Cells[0, 0].Value = dateValue.ToShortDateString();
            FpSpread1.Cells[1, 0].Value = dateValue.AddDays(1).ToShortDateString();
            FpSpread1.Cells[2, 0].Value = dateValue.AddDays(2).ToShortDateString();
            FpSpread1.Cells[3, 0].Value = dateValue.AddDays(3).ToShortDateString();
            FpSpread1.Cells[4, 0].Value = dateValue.AddDays(4).ToShortDateString();
            FpSpread1.Cells[5, 0].Value = dateValue.AddDays(5).ToShortDateString();
            FpSpread1.Cells[6, 0].Value = dateValue.AddDays(6).ToShortDateString();
    
        }
    }
    
    Visual Basic
    Copy Code
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Thread.CurrentThread.CurrentCulture = New CultureInfo("nl-NL")
        FpSpread1.CalculationCulture = New CultureInfo("de-DE")
    
        If Not IsPostBack Then
            Dim dateValue As DateTime = DateTime.Now.Date
            FpSpread1.Sheets(0).Columns(0).Width = 200
            FpSpread1.Sheets(0).Columns(1).Width = 250
            FpSpread1.Sheets(0).ColumnHeader.Cells(0, 0).Text = "Dates"
            FpSpread1.Sheets(0).ColumnHeader.Cells(0, 1).Text = "Days Of Week in German"
            FpSpread1.Cells(0, 1).Formula = "TEXT(DATEVALUE(""" & dateValue & " ""),""dddd"")"
            FpSpread1.Cells(1, 1).Formula = "TEXT(DATEVALUE(""" & dateValue.AddDays(1) & " ""),""dddd"")"
            FpSpread1.Cells(2, 1).Formula = "TEXT(DATEVALUE(""" & dateValue.AddDays(2) & " ""),""dddd"")"
            FpSpread1.Cells(3, 1).Formula = "TEXT(DATEVALUE(""" & dateValue.AddDays(3) & " ""),""dddd"")"
            FpSpread1.Cells(4, 1).Formula = "TEXT(DATEVALUE(""" & dateValue.AddDays(4) & " ""),""dddd"")"
            FpSpread1.Cells(5, 1).Formula = "TEXT(DATEVALUE(""" & dateValue.AddDays(5) & " ""),""dddd"")"
            FpSpread1.Cells(6, 1).Formula = "TEXT(DATEVALUE(""" & dateValue.AddDays(6) & " ""),""dddd"")"
            FpSpread1.Cells(0, 0).Value = dateValue.ToShortDateString()
            FpSpread1.Cells(1, 0).Value = dateValue.AddDays(1).ToShortDateString()
            FpSpread1.Cells(2, 0).Value = dateValue.AddDays(2).ToShortDateString()
            FpSpread1.Cells(3, 0).Value = dateValue.AddDays(3).ToShortDateString()
            FpSpread1.Cells(4, 0).Value = dateValue.AddDays(4).ToShortDateString()
            FpSpread1.Cells(5, 0).Value = dateValue.AddDays(5).ToShortDateString()
            FpSpread1.Cells(6, 0).Value = dateValue.AddDays(6).ToShortDateString()
        End If
    End Sub