When defining replacement items, the value can be formatted using the CustomFormatString. See these other global configuration defaults in the Config property:
Name | Description | |
---|---|---|
CreateHeader | Create a header for tables. The default is true. | |
FalseText | The text when a boolean is false. The default is False | |
HeaderBackgroundColor | The background color of the header for tables. The default is Black | |
HeaderForegroundColor | The foreground color of the header for tables. The default is White | |
InsertPageBreaks | Insert page breaks when performing a search and replace of lists of items. The default is true. | |
InsertSpacesIntoEnumValues | Insert spaces into enum values based on capitilization. The default is True | |
InsertSpacesIntoHeaderColumns | Insert spaces into header columns for tables based on capitilization. The default is True | |
MinValueDateText | The default text when a date is DateTime.MinValue. The default is string.Empty | |
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" | |
NullText | The default text when a value is null. The default is string.Empty. | |
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 |