A template layout can contain multiple bound fields which depend on each other while expansion in the final Excel report.
For example, in the below image, the 'team' and 'name' are two bound fields in the template layout where team is the former cell and name is the latter cell. Now, the 'name' field will depend on the 'team' field to group or filter its values based on the team. Also, the direction of expansion of the 'name' field will be decided by the 'team' field. Here, team is the context cell of name.
When multiple fields bound to a data source are defined in a template layout, a relationship is established between them which is called 'Context' relationship. The former cell is called the context cell of latter cell. Based on this relationship, the data is filtered or grouped while expansion in the final report.
There are two types of context relationships:
The context of a cell is defined using the 'C' property. The data in cells expand vertically or horizontally depending on their context. A cell's context can be set in the below ways:
For example, in the below image, A1 is the context cell of B1 and expands vertically.
And, A1 is the context cell of A2 and expands horizontally.
The priority order in which context should be applicable on a cell is determined in the following order:
Explicit context > Default Context > Fallback context
The Fallback context can be defined in a cell using the Range property, in case no default or explicit context is defined. The cell that defines the range is followed as a context for other cells to expand.
For example, the below template layout is created to display the sales details for different camera models, which means the data needs to expand with repect to the model of the camera. Then after a break, the sales details need to be displayed for another model of the camera. Instead of adding context to every field, we can define the range R=B11:F16 for Camera model - {{ds.Name (R=B11:F16)}}, stating that the sales details need to expand and group with respect to the camera model.
The above template layout will generate the following Excel report: