Documents for Excel .NET Edition | GCDocuments
Templates / Template Configuration / Global Settings
In This Topic
    Global Settings
    In This Topic

    Global settings, in GcExcel Templates, are the settings which when defined are applied throughout the template. These settings save lots of effort when same properties need to be applied on several fields. Global settings can be applied in all the template layouts and even in multiple worksheets of a workbook.

    The global settings provided by GcExcel template are explained below:

    Global Settings Description Value
    TemplateOptions.KeepLineSize It specifies whether the row height and column width should be kept the same throughout the template

    Type: Boolean

    Value: True

    False (Default Value)

    TemplateOptions.InsertMode It specifies whether to insert extra cells or entire rows and columns when extra space is needed while expanding the template

    Type: String

    Value: Cells (Default Value)

    EntireRowColumn

    TemplateOptions.EmbedFontForFormFields It specifies whether the fonts used by form fields should be embedded in exported PDF file.

    Note: This setting is only applicable for PDF form fields

    Type: Boolean

    Value: True (Default Value)

    False

    Note: The scope of global settings is within a workbook only, which means, that all the worksheets in a workbook will apply the global settings.

    The global settings can be applied in GcExcel template by using either of the two ways explained below:

    Define Global Settings in Template Layout

    Global settings can be defined in Template layout in Excel in 'Name Manager' dialog box as shown below. The 'Name Manager' can be accessed by navigating through Formulas tab > Defined Names group, and then clicking the 'Name Manager'.

    Name Manager dialog

    Set Global Settings using Code

    The global settings can be defined in GcExcel after loading the Excel template by using built-in workbook defined names TemplateOptions. The Add method of INames interface can be used to apply the global settings. The method takes Name and RefersTo properties as the parameters:

    The value of Name property in built-in defined name is taken as the template global option's name. It is case-sensitive.

    The value of RefersTo property in built-in defined name is taken as the template global option's value. It is case-sensitive.

     

    Refer to the below example code to specify the global settings in template:

    C#
    Copy Code
    Workbook workbook = new Workbook();
    workbook.Open("template.xlsx");
    
    //Init template global settings
    workbook.Names.Add("TemplateOptions.KeepLineSize", "true");
    workbook.Names.Add("TemplateOptions.InsertMode", "EntireRowColumn");
    //Global setting for PDF form fields
    workbook.Names.Add("TemplateOptions.EmbedFontForFormFields", "true");
    
    //Add data source
    workbook.AddDataSource("ds", ds);
    
    
    //Invoke to process the template
    workbook.ProcessTemplate();
    
    workbook.Save("report.xlsx");

    This template example records the E-commerce sales of electronic goods in different areas of a country. You can also download the Excel template layout.

    KeepLineSize

    The below image shows the Excel report when 'TemplateOptions.KeepLineSize' is set to true.

     

    Setting set to true

    InsertMode

    The below image shows the Excel report when 'TemplateOptions.InsertMode' is set to EntireRowColumn. By doing this, the row height and outline groups of the rows are retained when the template expands.

    Setting set to false

    EmbedFontForFormFields

    This setting allows you to embed font files used by form fields in the PDF document generated by GcExcel.

    When true, any arbitrary character is displayed correctly even if your machine or browser does not have corresponding fonts installed. However, it may generate large sized PDF documents, especially when East Asian characters are used.
    When false, the generated PDF document is of optimal size but messy code will be displayed if your machine or browser does not have corresponding fonts installed.

    The below image shows the PDF form generated by GcExcel when 'TemplateOptions.EmbedFontForFormFields' is set to True. You can also download the Excel template layout used in below example.