Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Formulas in Cells / Using Language Package / Creating and Using a Custom Language Package
In This Topic
    Creating and Using a Custom Language Package
    In This Topic

    Spread for WinForms provides a set of eighteen language packages including support for Chinese, Czech, Danish, Dutch, Finnish, French, German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Swedish and Turkish languages.

    In case, your preferred language doesn't come under the list of the available built-in packages, you can create a custom language package as per your requirements.

    Using Code

    In order to create and use a custom language package in your spreadsheet, you can follow the steps shared below:

    Step 1 - Create the custom language package with function alias.

    C#
    Copy Code
    // Creating a custom French language package with functions alias, and mapping BuiltinFunction and
    StructuredItemSpecifier.
    private LanguagePackage CreateCustomFrenchLanguagePackage()
    {
      LanguagePackage languagePackage = new LanguagePackage("CustomFrench", "français");
      languagePackage.CreateFunctionAlias(BuiltinFunction.SUM, "SOMME");
      languagePackage.CreateFunctionAlias(BuiltinFunction.SUBTOTAL, "SOUS.TOTAL");
      languagePackage.MapAlias(StructuredItemSpecifiers.Headers, "En-têtes");
      languagePackage.MapAlias(StructuredItemSpecifiers.Totals, "Totaux");
      return languagePackage;
    }           
    
    VB
    Copy Code

    Private Function CreateCustomFrenchLanguagePackage() As LanguagePackage

    ' Creating a custom French language package with functions alias, and mapping BuiltinFunction and StructuredItemSpecifier.   

       LanguagePackage languagePackage = new LanguagePackage("CustomFrench", "français")
       languagePackage.CreateFunctionAlias(BuiltinFunction.SUM, "SOMME")
       languagePackage.CreateFunctionAlias(BuiltinFunction.SUBTOTAL, "SOUS.TOTAL")
       languagePackage.MapAlias(StructuredItemSpecifiers.Headers, "En-têtes")
       languagePackage.MapAlias(StructuredItemSpecifiers.Totals, "Totaux")
       return languagePackage

    End Function 

    Step 2 - Assign the custom language using LanguagePackage property.

    C#
    Copy Code

    // Assigning custom language using LanguagePackage property.
    fpSpread1.AsWorkbook().WorkbookSet.LanguagePackage = CreateCustomFrenchLanguagePackage();

    VB
    Copy Code

    'Assigning custom language using LanguagePackage property.
    fpSpread1.AsWorkbook().WorkbookSet.LanguagePackage = CreateCustomFrenchLanguagePackage()

    Step 3 - Use the custom language package, set the formulas in the spreadsheet and calculate cell values.

    C#
    Copy Code
    //Setting cell texts and formulas.
    fpSpread1.Sheets[0].Cells[1, 1].Text = "Last Name";
    fpSpread1.Sheets[0].Cells[1, 2].Text = "Value";
    fpSpread1.Sheets[0].Cells[2, 1].Text = "Smith";
    fpSpread1.Sheets[0].Cells[2, 2].Value = 50;
    fpSpread1.Sheets[0].Cells[3, 1].Text = "Vil";
    fpSpread1.Sheets[0].Cells[3, 2].Value = 10;
    fpSpread1.Sheets[0].Cells[4, 1].Text = "Press";
    fpSpread1.Sheets[0].Cells[4, 2].Value = 78;

    // Adding a table.
    TableView t = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2);
    t.TotalRowVisible = true;
    fpSpread1.ActiveSheet.Cells[0, 1].Formula = "\"Total of \"&table[[#En-têtes],[Value]]"; //Use localized keyword
    fpSpread1.ActiveSheet.Cells[0, 1].ColumnSpan = 2;
    fpSpread1.ActiveSheet.Cells[0, 3].Formula = "table[[#Totals],[Value]]"; //Use English keyword
    fpSpread1.ActiveSheet.Cells[7, 1].ColumnSpan = 2;
    fpSpread1.ActiveSheet.SetFormula(0, 0, "SUM(2,120)");
    fpSpread1.ActiveSheet.SetActiveCell(0, 3);
    VB
    Copy Code
    'Setting cell texts and formulas.
    fpSpread1.Sheets[0].Cells[1, 1].Text = "Last Name"
    fpSpread1.Sheets[0].Cells[1, 2].Text = "Value"
    fpSpread1.Sheets[0].Cells[2, 1].Text = "Smith"
    fpSpread1.Sheets[0].Cells[2, 2].Value = 50
    fpSpread1.Sheets[0].Cells[3, 1].Text = "Vil"
    fpSpread1.Sheets[0].Cells[3, 2].Value = 10
    fpSpread1.Sheets[0].Cells[4, 1].Text = "Press"
    fpSpread1.Sheets[0].Cells[4, 2].Value = 78
    'Adding a table.
    TableView t = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2)
    t.TotalRowVisible = true
    fpSpread1.ActiveSheet.Cells[0, 1].Formula = "\"Total of \"&table[[#En-têtes],[Value]]" 'Use localized keyword
    fpSpread1.ActiveSheet.Cells[0, 1].ColumnSpan = 2
    fpSpread1.ActiveSheet.Cells[0, 3].Formula = "table[[#Totals],[Value]]"; 'Use English keyword
    fpSpread1.ActiveSheet.Cells[7, 1].ColumnSpan = 2
    fpSpread1.ActiveSheet.SetFormula(0, 0, "SUM(2,120)")
    fpSpread1.ActiveSheet.SetActiveCell(0, 3)
    See Also