The data in the grid can be exported as a delimited text, Excel, HTML, PDF, or RTF file. The following table describes the methods used to export each file type:
File Type | Method | Description |
---|---|---|
All | ExportTo | Opens a dialog box in which the user can select the export format. |
Delimited Text | ExportToDelimitedFile | Exports the specified rows from the grid to the specified file as delimited text. |
Excel | ExportToExcel | Exports the grid to an Excel file. |
HTML | ExportToHTML | Exports the grid to an HTML file. |
ExportToPDF | Exports the grid to a PDF file. | |
RTF | ExportToRTF | Exports the grid to an RTF file. |
Users can export to available file types by setting the ExportTo method.
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.ExportTo();
|
This topic illustrates the following:
Clicking the Export button opens the TrueDBGrid Print/Export Options dialog box.
To set the ExportToDelimitedFile method, add the following code to the Click event of the Export button:
C# |
Copy Code
|
---|---|
private void button1_Click(object sender, EventArgs e) { c1TrueDBGrid1.ExportToDelimitedFile(@"c:\temp\composers.csv", C1.Win.C1TrueDBGrid.RowSelectorEnum.AllRows, ","); } |
Clicking the Export button creates a delimited text file in the temp directory specified in the code above. Each value in the file is separated by a comma:
TrueDBGrid allows exporting grid data to Microsoft Excel format by using either of the following methods:
It is important to note that time taken to export grid data to Excel format is very small when using the SaveExcel method. In comparison, the ExportToExcel method takes much longer to export data.
To set the SaveExcel method, add the following code to the Click event of the Export button:
C# |
Copy Code
|
---|---|
c1TrueDBGrid1.SaveExcel("../../GridData.xlsx");
|
Clicking the Export button creates an Excel file as given below:
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.SaveExcel("../../GridData.xlsx"); |
To set the ExportToExcel method, add the following code to the Click event of the Export button:
C# |
Copy Code
|
---|---|
c1TrueDBGrid1.ExportToExcel(@"c:\temp\composers.xls");
|
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.ExportToExcel(@"c:\temp\composers.xls"); |
Clicking the Export button creates an Excel file in the temp directory indicated in the code above:
To set the ExportToHTML method, add the following code to the Click event of the Export button:
C# |
Copy Code
|
---|---|
c1TrueDBGrid1.ExportToHTML(@"c:\temp\composers.html"); |
Clicking the Export button creates an HTML file in the temp directory indicated in the code above:
To set the ExportToPDF method, add the following code to the Click event of the Export button:
C# |
Copy Code
|
---|---|
c1TrueDBGrid1.ExportToPDF(@"c:\temp\composers.pdf");
|
Clicking the Export button creates a PDF file in the temp directory:
To set the ExportToRTF method, add the following code to the Click event of the Export button:
C# |
Copy Code
|
---|---|
c1TrueDBGrid1.ExportToRTF(@"c:\temp\composers.rtf");
|
Clicking the Export button creates a RTF file in the temp directory indicated in the code above: