At its simplest level, the .NET Word Reports Library allows you to perform a search and replace of text inside a word document. To create a single page report such as an invoice, receipt, packing slip, create a word document and then put in text to replace. Create a dictionary of replacment items. See the demo which is included with the install, it shows an example of creating an invoice.
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"; Dictionary<string, ReplacementItem> replacement = new Dictionary<string, ReplacementItem> { { "[ReplaceMe]", new ReplacementItem { Value = "This is a test" } } }; generator.GenerateWordReport(sourceDocumentPath, outputDocumentPath, replacement); |
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" Dim replacement As New Dictionary(Of String, ReplacementItem)() From {{ "[ReplaceMe]", New ReplacementItem With {.Value = "This is a test"} }} generator.GenerateWordReport(sourceDocumentPath, outputDocumentPath, replacement) |