Word Reports
Overriding Defaults
Basic Tasks > Overriding Defaults

When defining replacement items, the value can be formatted using the CustomFormatString.  See these other global configuration defaults in the Config property:

 

  Name Description
Public Property CreateHeader Create a header for tables. The default is true.  
Public Property FalseText The text when a boolean is false. The default is False  
Public Property HeaderBackgroundColor The background color of the header for tables. The default is Black  
Public Property HeaderForegroundColor The foreground color of the header for tables. The default is White  
Public Property InsertPageBreaks Insert page breaks when performing a search and replace of lists of items. The default is true.  
Public Property InsertSpacesIntoEnumValues Insert spaces into enum values based on capitilization. The default is True  
Public Property InsertSpacesIntoHeaderColumns Insert spaces into header columns for tables based on capitilization. The default is True  
Public Property MinValueDateText The default text when a date is DateTime.MinValue. The default is string.Empty  
Public Property NoItemsMessage When there are no items in a list or data table the NoItemsMessage will show on the second row. The default is "No items found"  
Public Property NullText The default text when a value is null. The default is string.Empty.  
Public Property TrueText The text when a boolean is true. The default is True  

 

Here is an example of overridding the the default text for boolean values when they are false:

 

C#
//To run this example code, create a word document called ExampleTemplate.docx with the text [ReplaceMe] in the document
 
WordReportsGenerator generator = new WordReportsGenerator(); //Trial Mode
//WordReportsGenerator generator = new WordReportsGenerator("place user name here", "place license key here"); //License Mode
 
const string sourceDocumentPath = @"Test Documents\ExampleTemplate.docx";
const string outputDocumentPath = "ExampleOutput.docx";
 
using (Document document = generator.DocumentFactory(sourceDocumentPath))
{
    Dictionary<string, ReplacementItem> replacement =
        new Dictionary<string, ReplacementItem>
        {
            {
                "[ReplaceMe]",
                new ReplacementItem { Value = false }
            }
        };
 
    generator.Config.FalseText = "No";
 
    generator.Replace(document, replacement);
 
    generator.SaveDocument(document, outputDocumentPath);
}

VB.NET
'To run this example code, create a word document called ExampleTemplate.docx with the text [ReplaceMe] in the document
 
Dim generator As New WordReportsGenerator() 'Trial Mode
'WordReportsGenerator generator = new WordReportsGenerator("place user name here", "place license key here"); //License Mode
 
Const sourceDocumentPath As String = "Test Documents\ExampleTemplate.docx"
Const outputDocumentPath As String = "ExampleOutput.docx"
 
Using document As Document = generator.DocumentFactory(sourceDocumentPath)
    Dim replacement As New Dictionary(Of String, ReplacementItem)() From {{ "[ReplaceMe]", New ReplacementItem With {.Value = False} }}
 
    generator.Config.FalseText = "No"
 
    generator.Replace(document, replacement)
 
    generator.SaveDocument(document, outputDocumentPath)
End Using