RadControls for ASP.NET AJAX
ExcelML is XML-based file format. It complies to the Microsoft XMLSS specification and is supported in Microsoft Office 2003 and later. It is different from the rest of the export formats supported by RadGrid since its engine builds the output directly from the datasource and not from the page.
ExcelML format works best with advanced data-binding or data source control. You will receive "NullReferenceException" if you use simple data-binding and !IsPostBack (Not IsPostBack) check.
There are two events, dedicated for the ExcelML format: ExcelMLExportRowCreated and ExcelMLExportStylesCreated.
It is expected to receive the following warning when opening the generated xls file in Microsoft Office 2007.
The file you are trying to open, 'Filename.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening this file. Do you want to open the file now?
The cause of this warning message is explained in details in the following blog posts:
MSDN blogs: Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site
Grinn blog: "The file you are trying to open, '[filename]', is in a different format"
When exporting arrays, ArrayList, custom objects, LinqDataSource you should set UseAllDataFields="true" in MasterTableView.
It is mandatory to set the ExportOnlyData property to true when using ExcelML format. Otherwise, an exception will be thrown.
Due to limitation in the ExcelML engine, when exporting RadGrid with grouping, all groups will be expanded regardless of their actual state.
From Q2 2013 ExcelML supports exporting of GridHyperLinkColumn.
It is important to know that when its DataTextField property is set, other
columns bound to the same field are not exported. Also when Text property of the
GridHyperLinkColumn is set and DataField is not defined, columns added
to the DataNavigateUrlFields are not exported.
This event is handy when the developer wants to modify the structure of the exported table or when assigning styles to grid table elements. It occurs when the ExcelML engine creates a new row.
RadGrid fires this event when creating the build-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 ExcelMLExportRowCreated) custom style.
You can access the styles' collection through the Styles property (GridExportExcelMLStyleCreatedArgs).
This event triggers when the XMLSS structure is fully created. It could be useful when you need to traverse that structure or get the whole XML.
The ID's of the built-in styles are listed below:
The following code-snippet modifies the default itemStyle/alternatingItemStyle:
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.
You add the symbols from the table below to data of the header / footer elements in order to format them:
Number of pages
Font name, style, and size
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.
Cell background color
Cell background pattern
For more information about the number formats/borders, please visit the following link:
XML Spreadsheet reference
In addition to the predefined formats,you could add your own custom formats.
Each StyleElement has a Borders property (BorderStylesCollection) that contains the definition of each border. Border position should be specified using the PositionType enumeration:
You can use the HideStructureColumns property to hide GridRowIndicatorColumn, GridExpandColumn and GridGroupSplitterColumn. For the other columns types, you can use the following approach:
ExcelML is the only excel format which provides build in auto filter functionality.
To remove the filter controls from the header row set the Range property to empty string.
(e.Worksheet.AutoFilter.Range = ""). By setting the range you could move the filter on a different place within the excel sheet.
Only the data placed below the filtering dropdown menu will be included in the filter range. (Example: e.Worksheet.AutoFilter.Range = "R4C1: R4C5")
Generally speaking, R1C1 notation is another way to create cell references which uses numbers for both the rows and columns.
R1C1 stands for row index and column index number. This notation is only useful in RadGrid for setting the AutoFilter range.
ExcelML is one of the excel format which supports cells protection.
When you enable the worksheet protection all the cells will be protected as the default state of the cells is “locked”.
In order to unlock them you have to create a custom StyleElement and set its IsProtected property to false.
Then you could apply this style to the cells which should be unlocked.
The example below demonstrates how you could remove the protection on each second row: