Spread WPF 18
Features / Formulas and Functions / Language Packages
In This Topic
    Language Packages
    In This Topic

    Spread for WPF allows you to use language packs in worksheets. By utilizing language packs, you can set the desired language for processing the worksheet and display function names and formula keywords in the chosen language. This feature is achieved by creating function aliases in the specified language, making it easier to manage worksheets.

    Each language pack includes localized functions for both simple and advanced calculations. For example, the "SUM" function in the English language pack is represented as "SUMME" in the German language pack.

    Available Language Packs

    Spread for WPF includes 19 built-in language packs that allow you to display function names, special function logic, CalcError names, formula keywords, Boolean values, and more in the localized language. Additionally, other terms and screen tips can be displayed in the selected language.

    By default, the English language pack is applied. To use your local language, you can choose from the following built-in language packs:

    To set the language pack for a workbook, you can use the LanguagePackage property of the IWorkbookSet interface.

    Refer to the following example code to set the language pack to “German”.

    Copy Code
    // Set language pack to “German”.
    spreadSheet1.Workbook.WorkbookSet.LanguagePackage = GrapeCity.Spreadsheet.Localization.LanguagePackage.German;
    
    Copy Code
    ' Set language pack to “German”.
    spreadSheet1.Workbook.WorkbookSet.LanguagePackage = GrapeCity.Spreadsheet.Localization.LanguagePackage.German
    

    Custom Language Pack

    You can create a custom language pack to display function names, formula keywords, screen tips, boolean values, CalcError clauses, and other terms in a specific language.

    Steps to Create and Use a Custom Language Pack:

    1. Create a custom language pack along with aliases using the LanguagePackage class in the GrapeCity.Spreadsheet.Localization namespace.
    2. Assign the custom language using the LanguagePackage property of the IWorkbookSet interface.
    3. Use the custom language pack to set formulas and calculate cell values in a worksheet.

    The following image illustrates how a custom-defined language pack works within a worksheet.

     

    Refer to the following example code to create and use a custom language pack.

    Copy Code
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
      // Create custom language pack.
      GrapeCity.Spreadsheet.Localization.LanguagePackage languagePackage = new GrapeCity.Spreadsheet.Localization.LanguagePackage("CustomFrench", "français");
      languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUM, "SOMME");
      languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUBTOTAL, "SOUS.TOTAL");
      languagePackage.MapAlias(GrapeCity.CalcEngine.StructuredItemSpecifiers.Headers, "En-têtes");
      languagePackage.MapAlias(GrapeCity.CalcEngine.StructuredItemSpecifiers.Totals, "Totaux");
      // Assign custom language pack using LanguagePackage property.
      spreadSheet1.Workbook.WorkbookSet.LanguagePackage = languagePackage;
      // Set formula and cell’s text.
      spreadSheet1.Workbook.ActiveSheet.Cells[1, 0].Text = "First Name";
      spreadSheet1.Workbook.ActiveSheet.Cells[1, 1].Text = "Last Name";
      spreadSheet1.Workbook.ActiveSheet.Cells[1, 2].Text = "Value";
      spreadSheet1.Workbook.ActiveSheet.Cells[2, 0].Text = "John";
      spreadSheet1.Workbook.ActiveSheet.Cells[2, 1].Text = "Smith";
      spreadSheet1.Workbook.ActiveSheet.Cells[2, 2].Value = 50;
      spreadSheet1.Workbook.ActiveSheet.Cells[3, 0].Text = "Charles";
      spreadSheet1.Workbook.ActiveSheet.Cells[3, 1].Text = "Vil";
      spreadSheet1.Workbook.ActiveSheet.Cells[3, 2].Value = 10;
      spreadSheet1.Workbook.ActiveSheet.Cells[4, 0].Text = "Amy";
      spreadSheet1.Workbook.ActiveSheet.Cells[4, 1].Text = "Press";
      spreadSheet1.Workbook.ActiveSheet.Cells[4, 2].Value = 78;
      spreadSheet1.Workbook.ActiveSheet.Columns[0, 1].ColumnWidth = 100;
      spreadSheet1.Workbook.ActiveSheet.Columns[2, 3].ColumnWidth = 100;
      spreadSheet1.Workbook.ActiveSheet.Cells[0, 0].Text = "SOMME:";
      spreadSheet1.Workbook.ActiveSheet.Cells[0, 2].Text = "SOUS.TOTAL:";
      spreadSheet1.Workbook.ActiveSheet.Cells[0, 1].Formula = "SUM(2,120)";
      spreadSheet1.Workbook.ActiveSheet.Cells[0, 3].Formula = "SUBTOTAL(3, C3:C5 )";
      spreadSheet1.Workbook.ActiveSheet.Cells[0, 3].Activate();    
    }
    
    private GrapeCity.Spreadsheet.Localization.LanguagePackage CreateCustomFrenchLanguagePackage()
    {
         GrapeCity.Spreadsheet.Localization.LanguagePackage languagePackage = new GrapeCity.Spreadsheet.Localization.LanguagePackage("CustomFrench", "français");
         languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUM, "SOMME");
         languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUBTOTAL, "SOUS.TOTAL");
         return languagePackage;
    }
    
    Copy Code
    Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
        ' Create custom language pack.
        Dim languagePackage As GrapeCity.Spreadsheet.Localization.LanguagePackage = New GrapeCity.Spreadsheet.Localization.LanguagePackage("CustomFrench", "français")
        languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUM, "SOMME")
        languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUBTOTAL, "SOUS.TOTAL")
        languagePackage.MapAlias(GrapeCity.CalcEngine.StructuredItemSpecifiers.Headers, "En-têtes")
        languagePackage.MapAlias(GrapeCity.CalcEngine.StructuredItemSpecifiers.Totals, "Totaux")
        ' Assign custom language pack using LanguagePackage property.
        spreadSheet1.Workbook.WorkbookSet.LanguagePackage = languagePackage
        ' Set formula and cell’s text.
        spreadSheet1.Workbook.ActiveSheet.Cells(1, 0).Text = "First Name"
        spreadSheet1.Workbook.ActiveSheet.Cells(1, 1).Text = "Last Name"
        spreadSheet1.Workbook.ActiveSheet.Cells(1, 2).Text = "Value"
        spreadSheet1.Workbook.ActiveSheet.Cells(2, 0).Text = "John"
        spreadSheet1.Workbook.ActiveSheet.Cells(2, 1).Text = "Smith"
        spreadSheet1.Workbook.ActiveSheet.Cells(2, 2).Value = 50
        spreadSheet1.Workbook.ActiveSheet.Cells(3, 0).Text = "Charles"
        spreadSheet1.Workbook.ActiveSheet.Cells(3, 1).Text = "Vil"
        spreadSheet1.Workbook.ActiveSheet.Cells(3, 2).Value = 10
        spreadSheet1.Workbook.ActiveSheet.Cells(4, 0).Text = "Amy"
        spreadSheet1.Workbook.ActiveSheet.Cells(4, 1).Text = "Press"
        spreadSheet1.Workbook.ActiveSheet.Cells(4, 2).Value = 78
        spreadSheet1.Workbook.ActiveSheet.Columns(0, 1).ColumnWidth = 100
        spreadSheet1.Workbook.ActiveSheet.Columns(2, 3).ColumnWidth = 100
        spreadSheet1.Workbook.ActiveSheet.Cells(0, 0).Text = "SOMME:"
        spreadSheet1.Workbook.ActiveSheet.Cells(0, 2).Text = "SOUS.TOTAL:"
        spreadSheet1.Workbook.ActiveSheet.Cells(0, 1).Formula = "SUM(2,120)"
        spreadSheet1.Workbook.ActiveSheet.Cells(0, 3).Formula = "SUBTOTAL(3, C3:C5 )"
        spreadSheet1.Workbook.ActiveSheet.Cells(0, 3).Activate()
    End Sub
    Private Function CreateCustomFrenchLanguagePackage() As GrapeCity.Spreadsheet.Localization.LanguagePackage
        Dim languagePackage As GrapeCity.Spreadsheet.Localization.LanguagePackage = New GrapeCity.Spreadsheet.Localization.LanguagePackage("CustomFrench", "français")
        languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUM, "SOMME")
        languagePackage.CreateAlias(GrapeCity.CalcEngine.BuiltinFunction.SUBTOTAL, "SOUS.TOTAL")
        Return languagePackage
    End Function