Word Reports
CustomFormatString Property (ReplacementItem)
Example 



KellermanSoftware.WordReports Namespace > ReplacementItem Class : CustomFormatString Property
A .NET Custom Format String for single values such as decimal and DateTime. Does not apply to List<T> or DataTable Values.
Syntax
Public Property CustomFormatString As String
Dim instance As ReplacementItem
Dim value As String
 
instance.CustomFormatString = value
 
value = instance.CustomFormatString
public string CustomFormatString {get; set;}
public:
property String^ CustomFormatString {
   String^ get();
   void set (    String^ value);
}
Example
//To run this example code, create a word document called ExampleTemplate.docx with the text [InvoiceDate] 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";
 
Dictionary<string, ReplacementItem> replacement =
    new Dictionary<string, ReplacementItem>
        {
            {
                "[InvoiceDate]",
                new ReplacementItem { Value = DateTime.Now, CustomFormatString = "MM/dd/yyyy" }
            }
        };
 
generator.GenerateWordReport(sourceDocumentPath,
                              outputDocumentPath,
                              replacement);
'To run this example code, create a word document called ExampleTemplate.docx with the text [InvoiceDate] 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"
 
Dim replacement As New Dictionary(Of String, ReplacementItem)() From {{ "[InvoiceDate]", New ReplacementItem With {.Value = Date.Now, .CustomFormatString = "MM/dd/yyyy"} }}
 
generator.GenerateWordReport(sourceDocumentPath, outputDocumentPath, replacement)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ReplacementItem Class
ReplacementItem Members