Application Programming Interface
- 3 minutes to read
This topic provides a software developer’s perspective on the architecture of Snap Report API, including its object model overview.
The topic includes the following sections.
Snap Report Application Programming Interface
To create documents in code, Snap Report API includes the following main elements.
- SnapDocument provides methods, properties and events to manage a document’s content, data sources and parameters.
SnapList is an area of a Snap document, which uses templates to define the layout and formatting of data. These templates have a basic tabular structure that follows that of the Table class. In the created document, these templates are serialized as field codes that use a special markup.
To provide data shaping capabilities, the Snap list exposes the following properties:
The following elements provide the functionality required to present data in Snap documents:
Refer to the Examples section for code examples illustrating the programmatic generation of a document’s layout using the above API elements.
Each Snap Field in a document corresponds to a specific SnapEntity that is returned by the ISnapFieldOwner.ParseField method. Any modification of an entity at runtime must be wrapped in the SnapEntity.BeginUpdate and SnapEntity.EndUpdate method calls.
After calling the SnapEntity.BeginUpdate method, the SnapEntity.Active property becomes enabled until the SnapEntity.EndUpdate method is called. A document can only contain one active entity at one time.
The following requirements apply to the proper customization of a Snap entity at runtime.
To learn whether or not the customization is opened for an entity, consult its SnapEntity.Active property value.
To learn whether or not the customization is opened for a specific entity, use the ISnapFieldOwner.ActiveEntity property.
To open an entity for runtime customization, call its SnapEntity.BeginUpdate method.
To apply the new settings, call the SnapEntity.EndUpdate method.
Do not call the SnapEntity.EndUpdate method for a parent entity until there is no active nested entity left within it.
If a document contains multiple entities that are nested inside each other (e.g., in case of a master-detail report), only the outermost (parent) field in this document is active.
To modify the content of a nested field within a parent field’s document, do the following.
- Obtain the nested field from a corresponding SnapDocument.
- Parse the field by calling the ISnapFieldOwner.ParseField method that returns the appropriate SnapEntity.
- Call the SnapEntity.BeginUpdate method of the returned entity.
- After making the required changes, make sure to call the SnapEntity.EndUpdate method for the nested entity.
- Call the SnapEntity.EndUpdate method for the parent entity.