Excel-ExcelML (XLS) Export
ExcelML exports the Grid to an XML-based Excel Document that complies with the Microsoft XMLSS specification and is supported in Microsoft Office 2003 and later.
Unlike the other supported Formats, ExcelML functionality builds the output directly from the DataSource.
Diagram illustrating which sources are exported using different Export Formats

Due to the nature of ExcelML format, there are certain limitations. For more details, you can check out the Limitations section.
Usage
To export the Grid using ExcelML, there are two properties that need to be set:
- set the Excel-Format property to ExcelML within the
ExportSettingselement. - set the ExportOnlyData property to true within the
ExportSettingselement (mandatory for ExcelML)
Example
<telerik:RadGrid ID="RadGrid1" runat="server">
<ExportSettings ExportOnlyData="true">
<Excel Format="ExcelML" />
</ExportSettings>
</telerik:RadGrid>
When exporting Arrays, ArrayList, Custom Objects, LinqDataSource the UseAllDataFields must be set to true in MasterTableView.
Example
<telerik:RadGrid ID="RadGrid1" runat="server">
<ExportSettings ExportOnlyData="true">
<Excel Format="ExcelML" />
</ExportSettings>
<MasterTableView UseAllDataFields="true">
</MasterTableView>
</telerik:RadGrid>
When Exporting to ExcelML format, it is recommended to use Programmatic Data Binding with the NeedDataSource event or binding data with Declarative DataSource controls.
Export Events
Server-Side events dedicated for the ExcelML format.
-
OnExcelMLRowCreated: This event is triggered when a new row is created for the Excel Document. It could be handy when the developer wants to modify the structure of the exported table or when assigning styles to grid table elements.
-
OnExcelMLStylesCreated: This event is triggered when creating the built-in styles. It could be used not only for modifying the predefined styles but also to define your own (already assigned to a grid table element on OnExcelMLExportRowCreated) custom style. You can access the styles' collection through the
e.Stylesproperty. For more details, check out the Styles section. -
OnExcelMLWorkbookCreated: This event is triggered when the Excel Document (XMLSS) structure is fully created. It could be useful when you need to traverse that structure and make changes or get the whole XML output.
Customizing the Export Output
- Default Cell Alignment
- Changing the Built-in Styles
- Adding Custom Styles
- Styling the Header & Footer
- StyleElement object
- Number formats
- Borders
- Hiding columns
- Auto Filter
- Cells Protection
- Print option
Default Cell Alignment
You can specify a default alignment to all cells by using DefaultCellAlignment. This property is supported since Q2 2015 and its default value is NotSet. Typical values include Left, Right and Center.
<ExportSettings>
<Excel DefaultCellAlignment="Center" />
</ExportSettings>
Additionally you can change the default alignment within the OnExcelMLStylesCreated event.
Changing the Built-in Styles
The ID's of the built-in styles are listed below:
- headerStyle
- itemStyle
- alternatingItemStyle
- dateItemStyle
- alternatingDateItemStyle
Example code to change the default item and alternating item styles
protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
{
foreach (StyleElement style in e.Styles)
{
switch (style.Id)
{
case "itemStyle":
style.FontStyle.Color = System.Drawing.Color.LightBlue;
break;
case "alternatingItemStyle":
style.FontStyle.Color = System.Drawing.Color.Blue;
break;
}
}
}Adding Custom Styles
In order to define a custom style, you should assign it to the desired element (on GridExportExcelMLRowCreated) and then add the style to the collection on GridExportExcelMLStyleCreated event.
protected void RadGrid1_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
{
e.Row.Cells.GetCellByName("Name").StyleValue = "myCustomStyle";
}
protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
{
StyleElement myStyle = new StyleElement("myCustomStyle");
myStyle.NumberFormat.FormatType = NumberFormatType.Currency;
myStyle.FontStyle.Bold = true;
e.Styles.Add(myStyle);
}Styling the Header & Footer
You add the symbols from the table below to data of the header / footer elements in order to format them:
| Metadata | Represents |
|---|---|
| &L | Left-aligned data |
| &R | Right-aligned data |
| &C | Center-aligned data |
| &D | Date |
| &T | Time |
| &P | Page number |
| &N | Number of pages |
| &\0022fontname,fontstyle\0022&fontsize | Font name, style, and size |
| &B | Bold |
| &I | Italic |
protected void RadGrid1_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
{
e.Row.Cells.GetCellByName("Name").StyleValue = "myCustomStyle";
}
protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
{
StyleElement myStyle = new StyleElement("myCustomStyle");
myStyle.NumberFormat.FormatType = NumberFormatType.Currency;
myStyle.FontStyle.Bold = true;
e.Styles.Add(myStyle);
}StyleElement object
This object contains the whole information about a particular style. Fonts, colors, borders, number formats, cell alignment, etc could be applied by modifying the StyleElement.