Xceed Grid for WinForms provides events that are raised when the various XML elements in an exported spreadsheet are being written. The following table lists these events:
Event | Description |
---|---|
WritingCell | Raised when a Cell element is being written. |
WritingColumn | Raised when a Column element is being written. |
WritingRow | Raised when a Row element is being written. |
WritingTable | Raised when a Table element is being written. |
WritingWorkbook | Raised when a Workbook element is being written. |
WritingWorksheet | Raised when a Worksheet element is being written. |
The WritingCell event will be demonstrated in this topic. The use of ExcelExporter's CustomStyles property will also be demonstrated. This property holds a collection of ExcelStyle objects that can be used to modify the appearance of elements in the spreadsheet. The code below uses the Northwind database as an example. The style of a cell is changed in the EmployeeID column if it has a value of 4.
To subscribe to the WritingCell event, the following steps must be performed:
Obtain a reference to an ExcelExporter object.
Subscribe to the WritingCell event of the ExcelExporter object using the WritingCellElementEventHandler delegate class
Create a new method that will handle the events that are raised.
Place the desired code in the newly created event handler.
To subscribe to the WritingCell event, the following steps must be performed:
Obtain a reference to an ExcelExporter object.
Subscribe to the WritingCell event of the ExcelExporter object using the AddHandler/AddressOf keywords.
Create a new method that will handle the events that are raised.
Place the desired code in the newly created event handler.
This example assumes that you are in a Windows application.
VB.NET | Copy Code |
---|---|
Imports Xceed.Grid.Exporting |
C# | Copy Code |
---|---|
using Xceed.Grid.Exporting; |