---
title: "Appendix C. Typical Templates in C#"
---

```

## Purpose Summary

This page explains typical document templates used for mail merge and LINQ reporting.

```

This section contains examples of templates for typical scenarios. Every example is given using one of the following data source objects:

- `manager`, an instance of the `Manager` class
- `managers`, an enumeration of instances of the `Manager` class
- `contracts`, an enumeration of instances of the `Contract` class
- `clients`, an enumeration of instances of the `Client` class

The `Manager`, `Contract`, and `Client` classes are defined as follows.

```csharp
public class Manager
{
	public String Name { get { ... } }
	public int Age { get { ... } }
	public byte[] Photo { get { ... } }
	public Country Country { get { ... } }
	public IEnumerable<Contract> Contracts { get { ... } }
	...
}

public class Country
{
	public String Name { get { ... } }
	...
}

public class Contract
{
	public Manager Manager { get { ... } }
	public Client Client { get { ... } }
	public float Price { get { ... } }
	public DateTime Date { get { ... } }
	...
}

public class Client
{
	public String Name { get { ... } }
	...
}
```

## Single-Row Template

### Template Example

| ![Single_Row_Template_Example-aspose-words-net](single-row-template-example2.png) | Name: &lt;&lt;[manager.Name]&gt;&gt;  Age: &lt;&lt;[manager.Age]&gt;&gt; |
| :- | :- |

### Report Example

| ![Single_Row_Report_Example-aspose-words-net](single-row-report-example1.png) | Name: John Smith  Age: 37 |
| :- | :- |

## In-Paragraph List Template

### Template Example

```csharp
We provide support for the following clients: <<foreach [in clients]>><<[IndexOf() != 0 ? ", " : ""]>><<[Name]>><</foreach>>
```

### Report Example

```csharp
We provide support for the following clients: A Company, B Ltd., C & D, E Corp., F & Partners, G & Co., H Group, I & Sons, J Ent.
```

## Bulleted List Template

### Template Example

```csharp
We provide support for the following clients:
    * <<foreach [in clients]>><<[Name]>>
<</foreach>>
```

### Report Example

```csharp
We provide support for the following clients:
    * A Company
    * B Ltd.
    * C & D
    * E Corp.
    * F & Partners
    * G & Co.
    * H Group
    * I & Sons
    * J Ent.
```

## Numbered List Template

### Template Example

```csharp
We provide support for the following clients:
    1. <<foreach [in clients]>><<[Name]>>
<</foreach>>
```

### Report Example

```csharp
We provide support for the following clients:
    1. A Company
    2. B Ltd.
    3. C & D
    4. E Corp.
    5. F & Partners
    6. G & Co.
    7. H Group
    8. I & Sons
    9. J Ent.
```

## Multicolored Numbered List Template

### Template Example

<table class="conditional block">
	<tbody>
		<tr>
      <td><p>We provide support for the following clients:</p><p>1. &lt;&lt;foreach [in clients]>>&lt;&lt;if [IndexOf() % 2 == 0]>>&lt;&lt;[Name]>></p>
<p>2. &lt;&lt;else>>&lt;&lt;[Name]>></p><p>&lt;&lt;/if>>&lt;&lt;/foreach>></p></td>
		</tr>
	</tbody>
</table>

### Report Example

<table class="conditional block">
	<tbody>
		<tr>
      <td><p>We provide support for the following clients:</p><p>1. A Company</p><p>2. B Ltd.</p><p>3. C & D</p><p>4. E Corp.</p><p>5. F & Partners</p><p>6. G & Co.</p><p>7. H Group</p><p>8. I & Sons</p><p>9. J Ent.</p></td>
		</tr>
	</tbody>
</table>

## Common List Template

### Template Example

| &lt;&lt;foreach [in managers]&gt;&gt;  ![Common_List_Template_Example2-aspose-words-net](common-list-template-example2.png)  &lt;&lt;[Name()]&gt;&gt;  &lt;&lt;/foreach&gt;&gt; |
| :- |

### Report Example

| ![Single_Row_Report_Example1-aspose-words-net](single-row-report-example1.png)  John Smith  ![Single_Row_Report_Example-aspose-words-net](single-row-report-example1.png)  Tony Anderson  ![Single_Row_Report_Example-aspose-words-net](single-row-report-example1.png)  July James |
| :- |

## In-Table List Template

### Template Example

| Manager | Contract Price |
| :- | :- |
| ```csharp <<foreach [in managers]>><<[Name()]>> ``` | ```csharp <<[Contracts().sum(c => c.Price())]>><</foreach>> ``` |
| ```csharp Total: ``` | ```csharp <<[sum(m => m.Contracts().sum(c => c.Price()))]>> ``` |

### Report Example

| Manager | Contract Price |
| :- | :- |
| John Smith | 2300000 |
| Tony Anderson | 1200000 |
| July James | 800000 |
| Total: | 4300000 |

## In-Table List Template (Horizontal)

### Template Example

<table class="c-template">
	<tbody>
		<tr>
      <td>**Manager**</td>
      <td>&lt;&lt;foreach [in managers] -horz>>&lt;&lt;[Name]>></td>
      <td>**Total:**</td>
    </tr>
    <tr>
      <td>**Contract Price**</td>
      <td>&lt;&lt;[Contracts.Sum( c => c.Price)]>>&lt;&lt;/foreach>></td>
      <td>&lt;&lt;[Sum( m => m.Contracts.Sum( c => c.getPrice()))]>></td>
		</tr>
	</tbody>
</table>

### Report Example

| Manager | John Smith | Tony Anderson | July James | Total: |
| :- | :- | -- | -- | -- |
| **Contract Price** | 2300000 | 1200000 | 800000 | 4300000 |

## In-Table List Template with Running (Progressive) Total

### Template Example

<table class="c-template">
	<tbody>
		<tr>
      <td colspan="2">&lt;&lt;var [total = 0.0]>></td>
    </tr>
    <tr>
      <td>**Client**</td>
      <td>**Total Contract Price**</td>
    </tr>
    <tr>
      <td>&lt;&lt;foreach [in contracts]>>&lt;&lt;[Client.Name]>></td>
      <td>&lt;&lt;var [total = total + Price]>>&lt;&lt;[total]>>&lt;&lt;/foreach>></td>
		</tr>
	</tbody>
</table>

### Report Example

| Client | Total Contract Price |
| :- | :- |
| **A Company** | 1200000 |
| **B Ltd.** | 1950000 |
| **C & D** | 2300000 |
| **E Corp.** | 2950000 |
| **F & Partners** | 3500000 |
| **G & Co.** | 3850000 |
| **H Group** | 4100000 |
| **I & Sons** | 4200000 |
| **J Ent.** | 4300000 |

## In-Table List Template with Highlighted Rows

### Template Example

<table class="c-template">
	<tbody>
    <tr>
      <td>**Client**</td>
      <td>**Contract Price**</td>
    </tr>
    <tr>
      <td style="background-color: #ffff00">&lt;&lt;foreach [in contracts]>>&lt;&lt;if [Price >= 1000000]>>&lt;&lt;[Client.Name]>></td>
      <td style="background-color: #ffff00">&lt;&lt;[Price]>></td>
		</tr>
    <tr>
      <td>&lt;&lt;else>>&lt;&lt;[Client.Name]>></td>
      <td>&lt;&lt;[Price]>>&lt;&lt;/if>>&lt;&lt;/foreach>></td>
		</tr>
    <tr>
      <td>Total:</td>
      <td>&lt;&lt;[Sum(c => c.Price)]>></td>
		</tr>
	</tbody>
</table>

### Report Example

<table class="c-template">
	<tbody>
    <tr>
      <td>**Client**</td>
      <td>**Contract Price**</td>
    </tr>
    <tr>
      <td style="background-color: #ffff00">A Company</td>
      <td style="background-color: #ffff00">1200000</td>
		</tr>
    <tr>
      <td>B Ltd.</td>
      <td>750000</td>
		</tr>
    <tr>
      <td>C &amp; D</td>
      <td>350000</td>
		</tr>
    <tr>
      <td>E Corp.</td>
      <td>650000</td>
		</tr>
    <tr>
      <td>F &amp; Partners</td>
      <td>550000</td>
		</tr>
    <tr>
      <td>G &amp; Co.</td>
      <td>350000</td>
		</tr>
    <tr>
      <td>H Group</td>
      <td>250000</td>
		</tr>
    <tr>
      <td>I &amp; Sons</td>
      <td>100000</td>
		</tr>
    <tr>
      <td>J Ent.</td>
      <td>100000</td>
		</tr>
    <tr>
      <td>Total:</td>
      <td>4300000</td>
		</tr>
	</tbody>
</table>

## In-Table List Template (Horizontal) with Highlighted Columns

### Template Example

<table class="c-template">
	<tbody>
		<tr>
      <td>**Manager**</td>
      <td style="background-color: #ffff00">&lt;&lt;foreach [in managers] -horz>>&lt;&lt;if [Contracts.Sum( c => c.Price) >= 2000000] -horz>>&lt;&lt;[Name]>></td>
      <td>&lt;&lt;else>>&lt;&lt;[Name]>></td>
      <td>**Total:**</td>
    </tr>
    <tr>
      <td>**Contract Price**</td>
      <td style="background-color: #ffff00">&lt;&lt;[Contracts.Sum( c => c.Price)]>></td>
      <td>&lt;&lt;[Contracts.Sum( c => c.Price)]>>&lt;&lt;/if>>&lt;&lt;/foreach>></td>
      <td>&lt;&lt;[Sum( m => m.Contracts.Sum( c => c.Price))]>></td>
		</tr>
	</tbody>
</table>

### Report Example

<table class="c-template">
	<tbody>
		<tr>
      <td>**Manager**</td>
      <td style="background-color: #ffff00">John Smith</td>
      <td>Tony Anderson</td>
      <td>July James</td>
      <td>**Total:**</td>
    </tr>
    <tr>
      <td>**Contract Price**</td>
      <td style="background-color: #ffff00">2300000</td>
      <td>1200000</td>
      <td>800000</td>
      <td>4300000</td>
		</tr>
	</tbody>
</table>

## In-Table List Template with Alternate Content

### Template Example

<table class="c-template">
	<tbody>
    <tr>
      <td>**Client**</td>
      <td>**Contract Price**</td>
    </tr>
		<tr>
      <td colspan="2" style="text-align: center">&lt;&lt;if [!Any()]>>No data</td>
    </tr>
    <tr>
      <td>&lt;&lt;else>>&lt;&lt;foreach [in contracts]>>&lt;&lt;[Client.Name]>></td>
      <td>&lt;&lt;[Price]>>&lt;&lt;/foreach>></td>
		</tr>
    <tr>
      <td>**Total:**</td>
      <td>&lt;&lt;[Sum(c => c.Price)]>>&lt;&lt;/if>></td>
		</tr>
	</tbody>
</table>

### Report Example 1

<table class="c-template">
	<tbody>
    <tr>
      <td>**Client**</td>
      <td>**Contract Price**</td>
    </tr>
		<tr>
      <td colspan="2" style="text-align: center">No data</td>
    </tr>
	</tbody>
</table>

### Report Example 2

| Client | Contract Price |
| :- | :- |
| **A Company** | 1200000 |
| **B Ltd.** | 750000 |
| **C & D** | 350000 |
| **E Corp.** | 650000 |
| **F & Partners** | 550000 |
| **G & Co.** | 350000 |
| **H Group** | 250000 |
| **I & Sons** | 100000 |
| **J Ent.** | 100000 |
| **Total:** | 4300000 |

## In-Table List Template (Horizontal) with Alternate Content

### Template Example

<table class="c-template">
	<tbody>
		<tr>
      <td>**Manager**</td>
      <td rowspan="2" style="vertical-align: middle">&lt;&lt;if [!Any()] -horz>>No data</td>
      <td>&lt;&lt;else>>&lt;&lt;foreach [in managers] -horz>>&lt;&lt;[Name]>></td>
      <td>**Total:**</td>
    </tr>
    <tr>
      <td>**Contract Price**</td>
      <td>&lt;&lt;[Contracts.Sum( c => c.Price)]>>&lt;&lt;/foreach>></td>
      <td>&lt;&lt;[Sum( m => m.Contracts.Sum( c => c.Price))]>>&lt;&lt;/if>></td>
		</tr>
	</tbody>
</table>

### Report Example 1

<table class="c-template">
	<tbody>
    <tr>
      <td>**Client**</td>
      <td rowspan="2" style="vertical-align: middle">No data</td>
    </tr>
		<tr>
      <td>**Contract Price**</td>
    </tr>
	</tbody>
</table>

### Report Example 2

| Manager | John Smith | Tony Anderson | July James | Total:  |
| :----------------- | :--------- | ------------- | ---------- | ------- |
| **Contract Price** | 2300000    | 1200000       | 800000     | 4300000 |

## Common Master-Detail Template

### Template Example

| &lt;&lt;foreach [in managers]&gt;&gt;  ![Common_List_Template_Example2-aspose-words-net](common-list-template-example2.png)  &lt;&lt;[Name()]&gt;&gt;  Clients: &lt;&lt;foreach [in Contracts() ]&gt;&gt;&lt;&lt;[indexOf() != 0 ? ", " : ""]&gt;&gt;&lt;&lt;[Client().Name()]&gt;&gt;&lt;&lt;/foreach&gt;&gt;  &lt;&lt;/foreach&gt;&gt; |
| :- |

### Report Example

| ![Single_Row_Report_Example1-aspose-words-net](single-row-report-example1.png)  John Smith  Clients: A Company, B Ltd., C & D  ![Single_Row_Report_Example1-aspose-words-net](single-row-report-example1.png)  Tony Anderson  Clients: E Corp., F & Partners  ![Single_Row_Report_Example1-aspose-words-net](single-row-report-example1.png)  July James  Clients: G & Co., H Group, I & Sons, J Ent. |
| :- |

## In-Table Master-Detail Template

### Template Example

| Manager/Client | Contract Price |
| :- | :- |
| ```csharp <<foreach [in managers]>><<[Name()]>> ``` | ```csharp <<[Contracts().sum(c => c.Price())]>> ``` |
| ```csharp <<foreach [in Contracts()]>> <<[Client().Name()]>> ``` | ```csharp <<[Price()]>><</foreach>><</foreach>> ``` |
| ```csharp Total: ``` | ```csharp <<[Sum(m => m.Contracts().Sum(c => c.Price()))]>> ``` |

### Report Example

| Manager/Client    | Contract Price |
| ----------------- | -------------- |
| **John Smith**    | 2300000        |
| *A Company*       | 1200000        |
| *B Ltd.*          | 750000         |
| *C & D*           | 350000         |
| **Tony Anderson** | 1200000        |
| *E Corp.*         | 650000         |
| *F & Partners*    | 550000         |
| **July James**    | 800000         |
| *G & Co.*         | 350000         |
| *H Group*         | 250000         |
| *I & Sons*        | 100000         |
| *J Ent.*          | 100000         |
| **Total:**        | 4300000        |

## Pie Chart Template

**Template Example**

![Pie_Chart_Template_Example2-aspose-words-net](pie-chart-template-example2-1.jpg)

**Initial Chart Series Data**

![Pie_Chart_Series_Data2-aspose-words-net](pie-chart-series-data2-1.jpg)

**Report Example**

![Pie_Chart_Report_Example-aspose-words-net](pie-chart-report-example.jpg)

## Sunburst Chart Template

**Template Example**

![sunburst-chart-template-aspose-words-net](sunburst-chart-template1.jpg)

**Initial Chart Series Data**

![sunburst-chart-example-aspose-words-net](sunburst-chart-example1.jpg)

**Report Example**

![sunburst-chart-report-aspose-words-net](sunburst-chart-report.jpg)

## Treemap Chart Template

**Template Example**

![treemap-chart-template-aspose-words-net](treemap-chart-template1.jpg)

**Initial Chart Series Data**

![sunburst-chart-example-aspose-words-net](sunburst-chart-example1.jpg)

**Report Example**

![treemap-chart-report-aspose-words-net](treemap-chart-report.jpg)

## Histogram Chart Template

**Template Example**

![Histigram_Chart_Template1-aspose-words-net](histogram-chart-template1.jpg)

**Report Example**

![Histigram_Chart_Report-aspose-words-net](histogram-chart-report.jpg)

## Scatter Chart Template

**Template Example**

![Scatter_Chart_Template_Example2-aspose-words-net](scatter-chart-template-example2-1.jpg)

**Initial Chart Series Data**

![Scatter_Chart_Series_Data2-aspose-words-net](scatter-chart-chart-series-data2-1.jpg)

**Report Example**

![Scatter_Chart_Report_Example-aspose-words-net](scatter-chart-report-example.png)

{{< gist "aspose-words" "9a306a41bb6aea8adfcabf5a575c5718" "Examples-CSharp-LINQ-ScatterChart-ScatterChart.cs" >}}

## Bubble Chart Template

**Template Example**

![Bubble_Chart_Template_Example2-aspose-words-net](bubble-chart-template-example2-1.jpg)

**Initial Chart Series Data**

![Bubble_Chart_Series_Data2-aspose-words-net](bubble-chart-series-data2-1.jpg)

**Report Example**

![Bubble_Chart_Report_Example-aspose-words-net](bubble-chart-report-example.png)

## In-Table Template with Filtering, Grouping, and Ordering

**Template Example**

| **Manager**                                                  | **Contract Price**                                           |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ```csharp<<foreach [in contracts .Where(c => c.Date.Year == 2015).GroupBy(c => c.Manager).OrderBy(g => g.Key.Name)]>><<[Key.Name]>>``` | ```csharp<<[Sum(c => c.Price)]>><</foreach>>``` |

**Report Example**

| Manager | Contract Price |
| :- | :- |
| **John Smith** | 2300000 |
| **July James** | 800000 |
| **Tony Anderson** | 1200000 |

## Chart Template with Filtering, Grouping, and Ordering

**Template Example**

![Chart_Template_Example2-aspose-words-net](chart-template-example2-1.jpg)

**Report Example**

![Chart_Report_Example-aspose-words-net](chart-report-example.png)
