Document Solutions for Excel, Java Edition | Document Solutions
Templates / Template Configuration / Global Settings
In This Topic
    Global Settings
    In This Topic

    Global settings, in DsExcel 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 DsExcel 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

    TemplateOptions.DebugMode It specifies whether to retain the original template data after the template has been expanded by keeping the template and the report in the same workbook.

    Type: Boolean

    Value: True

    False (Default Value)

    TemplateOptions.PaginationMode It limits the number of instances of a template cell generated on a page. When the number of instances exceeds the CountPerPage property value, a new page is automatically created with the same layout as the template.

    Type: Boolean

    Value: True

    False (Default Value)

    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 DsExcel 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 DsExcel 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:

    Java
    Copy Code
    Workbook workbook = new Workbook();
    workbook.open("template.xlsx");
     
    //Init template global settings
    workbook.getNames().add("TemplateOptions.KeepLineSize", "true");
    workbook.getNames().add("TemplateOptions.InsertMode", "EntireRowColumn");
                
    //Global setting for PDF form fields
    workbook.getNames().add("TemplateOptions.EmbedFontForFormFields", "true");
    
    //Init DebugMode setting
    workbook.getNames().add("TemplateOptions.DebugMode", "true");
                
    //Init template global settings 
    workbook.getNames().add("TemplateOptions.PaginationMode", "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 DsExcel.

    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 DsExcel when 'TemplateOptions.EmbedFontForFormFields' is set to True. You can also download the Excel template layout used in below example.

    Debug Mode

    By setting TemplateOptions.DebugMode to true, you can compare the generated report to its corresponding template within the same workbook.

    Below image shows the generated Excel report when TemplateOptions.DebugMode option is set to true.

    Template Sheet
    Report Sheet

    PaginationMode

    This setting ensures that CountPerPage template property is considered by the template engine. When TemplateOptions.PaginationMode is true, the worksheet paginates on basis of value set in CountPerPage template property. In such case, value of TemplateOptions.KeepLineSize is always considered as true. Also, value of TemplateOptions.InsertMode is considered as EntireRowColumn in the pagination mode.

    Below images show Page1 and Page2 of the generated Excel report when TemplateOptions.PaginatedMode is set to true along with CountPerPage template property.

    Page 1
    Page 2