Hello World Example

Contents
[ ]

Assume that you have the Sender class defined in your application as follows:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
public class Sender
{
public String Name { get; set; }
public String Message { get; set; }
}

To produce a report containing a message of a concrete sender on its behalf, you can use a template document with the following content.

<<[s.Name]>> says: "<<[s.Message]>>."

To build a report from the template, you can use the following source code.

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LINQ();
string fileName = "HelloWorld.doc";
// Load the template document.
Document doc = new Document(dataDir + fileName);
// Create an instance of sender class to set it's properties.
Sender sender = new Sender { Name = "LINQ Reporting Engine", Message = "Hello World" };
// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();
// Execute the build report.
engine.BuildReport(doc, sender, "sender");
dataDir = dataDir + RunExamples.GetOutputFilePath(fileName);
// Save the finished document to disk.
doc.Save(dataDir);

After the source code is executed, the template document is populated with the data about the sender, and the document becomes a ready report with the following content.

LINQ Reporting Engine says: "Hello, World."

After the report document is built, you can save it or perform any other tasks on it using Aspose.Words API in your code.