View on GitHub ClosedXML.Report

Tags list

Tag Parameters Scope Description
Range source, horizontal range Using the source parameter, you can specify a data source for an range other than the name of the range. By using the horizontal option, you can specify that the range should be horizontally constructed.
Sort asc, desc rangeCol Sorts the range by the column for which it is specified. The parameters Desc and Asc (Asc - by default) indicate the sort order. You can simultaneously sort by several columns. Sorting occurs from right to left, that is, first the rightmost column is sorted, then the next one is left, etc. The <sort> tag works both for separately located ranges, and for nested (the lowest level of nesting).
Asc   rangeCol Same as <sort desc>
Desc   rangeCol Same as <sort asc>
Group Collapse
Desc
Asc
MergeLabels=[Merge1| Merge2| Merge3]
PlaceToColumn=n
WithHeader
Disablesubtotals
DisableOutline
PageBreaks
rangeCol Creates subtotals on columns that have totals tags (<sum>, etc.), grouping them by the column for which it is specified. The range will be pre-sorted by all columns for which the Group, Sort, Desc, and Asc tags are specified. The sort order for the <group> tag is indicated by the optional parameter Desc or Asc (Asc by default). The Collapse parameter causes the intermediate totals to be rolled up to the level where the <group> tag is located with this parameter. The work of the tag is fully consistent with the Subtotal method of the Range object. Similarly, if the <group> tag is specified for multiple columns, the subtotals are grouped by all these columns. Grouping occurs from right to left, that is, first the results are grouped on the rightmost column for which the <group> tag is specified, then the column with the option <group> to the left of it, etc. To format the subtotal rows, you use the formatting of the area’s service line. After creating the subtotals, the service line is removed from the scope. The tag can be used without summary functions. In this case, the data is grouped without intermediate totals. To format the subtotal rows and group headers, formatting the area’s service line is used.
The MergeLabels parameter causes the group cells to be combined in a grouped column.
The parameter PlaceToColumn allows you to specify the column in which the group header will be placed.
The parameter DisableSubtotals allows you to disable the creation of subtotals for a column.
The DisableOutline parameter turns off the creation of the Outline view for a grouped column.
The PageBreaks parameter allows you to put each group on a separate page.
The WithHeader parameter allows you to create a group header when using subtotals. If the <SummaryAbove> tag is found (see below), the subtotals are placed above the data.
For more information, see Grouping
SummaryAbove   range A helper tag for the <group> tag. <SummaryAbove> is used to place totals on groups over data. For more information, see Grouping
DisableGrandTotal   range Prevents the creation of all totals when using an area grouping with subtotals. For more information, see Grouping
Pivot Name
Dst
RowGrand
ColumnGrand
NoPreserveFormatting
CaptionNoFormatting
MergeLabels
ShowButtons
TreeLayout
AutofitColumns
NoSort
  Creates a summary table for the range for which it is specified. The structure of the summary table is determined according to the options in the fields of the summary table (described below). The range on which the PivotTable is built must be an Excel data list. A header must be present above the scope.
The <pivot> tag requires the mandatory specification of the Name parameter specifying the name of the pivot table being created. The name must be valid in Excel.
The Dst parameter allows you to specify the exact location of the top-left corner of the pivot table (including page margins). The value of this parameter can be the cell reference formulas in styles A1 or R1C1. You can specify in this formula the name of the sheet on which you want to place the pivot table. For example, Dst = Sheet1! D8. If the parameter Dst is not specified, a new sheet with the name of this table is created for each report summary table.
The parameters RowGrand and ColumnGrand include the corresponding properties of the pivot table, allowing you to get the total results on the rows and, accordingly, the columns of the table.
MergeLabels includes the corresponding property of the PivotTable, invoking a union of cells in the row and column area.
By default, all formatting of the source area is transferred to the corresponding header and data area. If the NoPreserveFormatting parameter is specified, the formatting is not carried over.
The ShowButtons option allows you to show the expand / collapse button.
TreeLayout - sets the pivot table mode as a tree.
AutofitColumns - includes auto-match the width of the columns of the pivot table.
NoSort - disables automatic sorting of the pivot table.

Pivot table tags (Page, Row, Column, Data) are used to describe the structure of the pivot table, defining the areas of the pivot table into which these fields are placed. In conjunction with them, the final tags are used, describing the types of totals that must be obtained from these fields. Columns for which the PivotTable field tags are not specified are included in the summary table as hidden. In the process of working with a finished report using standard Excel tools, it is possible to modify the structure of the summary table by the end user. The structure of the PivotTable should take into account the restrictions on the summary tables, which are described in the documentation for the specific version of Excel. A detailed description of the methodology for calculating these constraints can be found in MSDN.

More information in the section Pivot tables
Page   rangeCol This tag places the column for which it is specified in the field of the pages in the pivot table. The field label is a cell value from the table header above the source area
Row   rangeCol This tag places the column for which it is specified in the area of ​​the rows in the pivot table. The field label is the cell value from the table header above the source area. Excel automatically groups the elements of the internal field for each element of the external field of the rows and, if necessary, creates subtotals. The type of subtotals is determined by an additional specify of the totals tag for the column with the tag <row>. For example, specifying the tags <row> <sum> <count> will create an amount and a count in the intermediate totals by the field of the pivot table, the source of which is the column with these tags.
Column, Col   rangeCol This tag places the column for which it is specified in the column area of the pivot table. The field label is the cell value from the table header above the source area. You can get one or more subtotals on column fields. Their type is determined by an additional indication of the totals tag for the column with the tag <col>. For example, specifying the options <col> <sum> <count> will create an amount and a count in the intermediate totals by the field of the pivot table, the source of which is the column with these tags.
Data   rangeCol This tag places the column for which it is specified in the pivot table data area. The field label is the cell value from the table header above the source area. By default, the sum function is applied to the data fields. To switch to any other summary function in the data field, jointly with the tag <data> you can use the totals tags.
SUM
AVG
AVERAGE
COUNT
COUNTNUMS
MAX
MIN
PRODUCT
STDEV
STDEVP
VAR
VARP
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
over=”expression”
rangeCol These are the tags of the totals. Specifying it for a column causes a summary of the column. The result is calculated by the corresponding Excel function. The results are placed in the service column of the range. On the column, you can get only one kind of total (for example, the amount or only the average). If several summary options are specified, only the last specified total is calculated. The over parameter allows you to make calculations using the power of .NET and LINQ. Expressions use the syntax of C# expressions. Using the items variable, you can access a list of table items.
OnlyValues   worksheet
range
rangeCol
cell
Replaces all formulas on the worksheet, in the region, in the column of the region, or in the cell where it is specified, by the values of these formulas.
AutoFilter   range Enables the AutoFilter in the area for which it is specified.
Protected Password=”password” workbook
worksheetrange
cell
rangeCol
If specified for the report, it protects all sheets and protects the book itself. If specified for a sheet, this sheet is protected. Analagically applied to the area, a certain column of the region and to a separate cell. The Password option is optional. If the password is not set, it will be generated randomly.
ColsFit   workbook
worksheet
worksheetCol
range
rangeCol
cell
Causes automatic alignment of column widths by value in the cells of the columns of the entire report (if specified for the report), the sheet (if specified for the sheet), the entire sheet column (if specified on the first line of the sheet), the range (if specified for the range), the range column (if specified in the options line) or for one cell. If specified for the sheet and for the range on this sheet, it is only called for the sheet. The same principle is applied from the greater to the less for the remaining cases.
RowsFit   workbook
worksheet
worksheetRow
range
rangeCol
cell
Causes automatic alignment of row height by value in the cells of the rows of the entire report (if specified for the report), the sheet (if specified for the sheet), the entire row of the sheet (if specified on the first column of the sheet), the range (if specified for the range) or for one cell. If specified for the sheet and for the range on this sheet, it is only called for the sheet. The same principle is applied from the greater to the less for the remaining cases.
Hidden, Hide   worksheet Hides the sheet for which it is specified. In the case of debugging the report, produces a “soft” hiding, which makes the sheet visible.
Delete   worksheet
worksheetRow
worksheetCol
rangeCol
Removes a sheet, a row/column of a sheet, or an range column, depending on where the tag is located.
PageOptions Wide=<int>
Tall=<int>
Landscape
workbook
worksheet
Specifies the page parameters for printing, adjusting the width of the sheet with the parameter Wide, the height of the sheet with the parameter Tall and the orientation of the sheet with the parameter Landscape