This example illustrates the Snap API that is used to generate a document from scratch and connect it to data completely in code.
The following code generates a tabular report layout. For a sample code that creates a mail-merge report (in the context of SnapDocumentServer), refer to the following example: How to automatically create mail-merge documents using the Snap Document Server.
SnapControl extends the RichEditControl's API and introduces the SnapList class that is used to insert dynamic data elements into a document.
To generate a data-aware Snap document, do the following:
- Create a Snap application and connect it to a data source.
- Add a SnapList to the SnapDocument.
- To generate the SnapList layout, define the ListHeader, ListFooter, and RowTemplate.
- Inject data fields into the document (e.g., by using SnapText to display text data).
- Format the document content (see the FormatList method implementation in the Form1.cs file of the sample solution).
- If required, apply grouping, sorting, and/or filtering to the SnapList content.
A SnapEntity is open to customization only after calling its BeginUpdate method and not after the EndUpdate method is called to apply the new settings (see the GenerateLayout method in the Form1.cs file of the sample solution).