Word Reports
HeaderText Property
Example 



KellermanSoftware.WordReports Namespace > ColumnDefinition Class : HeaderText Property
The text for the header
Syntax
Public Property HeaderText As String
Dim instance As ColumnDefinition
Dim value As String
 
instance.HeaderText = value
 
value = instance.HeaderText
public string HeaderText {get; set;}
public:
property String^ HeaderText {
   String^ get();
   void set (    String^ value);
}
Example
//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))
{
    DataTable dataTable = new DataTable();
    dataTable.Columns.Add("FirstName", typeof(string));
    dataTable.Columns.Add("LastName", typeof(string));
    dataTable.Columns.Add("BirthDate", typeof(DateTime));
 
    dataTable.Rows.Add("John", "Smith", DateTime.Now.AddYears(-40));
    dataTable.Rows.Add("Joe", "Jones", DateTime.Now.AddYears(-22));
 
    List<ColumnDefinition> columnDefinitions =
new List<ColumnDefinition>
        {
            new ColumnDefinition("LastName")
                {
                    HeaderText = "Last"
                },
            new ColumnDefinition("FirstName")
                 {
                    HeaderText = "First"
                },
            new ColumnDefinition("BirthDate")
                {
                    HeaderText = "Date of Birth"
                }
        };
 
    Dictionary<string, ReplacementItem> replacement =
        new Dictionary<string, ReplacementItem>
            {
                {
                    "[ReplaceMe]",
                    new ReplacementItem {Value = dataTable, ColumnDefinitions = columnDefinitions}
                }
            };
 
    generator.Replace(document, replacement);
    generator.SaveDocument(document, outputDocumentPath);
}
'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 dataTable As New DataTable()
    dataTable.Columns.Add("FirstName", GetType(String))
    dataTable.Columns.Add("LastName", GetType(String))
    dataTable.Columns.Add("BirthDate", GetType(Date))
 
    dataTable.Rows.Add("John", "Smith", Date.Now.AddYears(-40))
    dataTable.Rows.Add("Joe", "Jones", Date.Now.AddYears(-22))
 
    Dim columnDefinitions As New List(Of ColumnDefinition)() From { _
        New ColumnDefinition("LastName") With {.HeaderText = "Last"}, _
        New ColumnDefinition("FirstName") With {.HeaderText = "First"}, _
        New ColumnDefinition("BirthDate") With {.HeaderText = "Date of Birth"} _
    }
 
    Dim replacement As New Dictionary(Of String, ReplacementItem)() From {{ "[ReplaceMe]", New ReplacementItem With {.Value = dataTable, .ColumnDefinitions = columnDefinitions} }}
 
    generator.Replace(document, replacement)
    generator.SaveDocument(document, outputDocumentPath)
End Using
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

ColumnDefinition Class
ColumnDefinition Members