XtraReport.ExportToXls(String, XlsExportOptions) Method

Exports a report to the specified file path in XLS format using the specified XLS-specific options.This method exports data in WYSIWYG mode. Certain controls (e.g., a GridControl) can be exported to XLS(XLSX) format in a faster data-aware export mode, optimized for subsequent analysis of data in MS Excel. To learn how to employ data-aware export, see Export to XLS and XLSX Formats.

Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v18.1.dll
Syntax
public void ExportToXls(string path, XlsExportOptions options)
Parameters
Type Name Description
String path

A String which specifies the file name (including the full path) for the created XLS file.

XlsExportOptions options

A XlsExportOptions object which specifies the XLS export options to be applied when a report is exported.

Once the document export has started, it will run until the resulting document is complete and cannot be interrupted or canceled in the process.

Use this method to export a report to an XLS file using the specified XLS export options (like XlExportOptionsBase.ShowGridLines, XlExportOptionsBase.TextExportMode, etc.).

Note that in this instance the current report export options, which are represented by the XlsExportOptions object returned by the ExportOptions.Xls property of a report's XtraReport.ExportOptions, are ignored.

If, instead, you want to use the current export options of a report, you should call the overloaded XtraReport.ExportToXls method without the options parameter.

Note

This method overwrites any files present at the specified path that have the same file name without any warnings.

To learn more, see Export to XLS.

Examples

The following example demonstrates how to export a report to XLS format. To do this, the XtraReport.ExportToXls method should be used. It also demonstrates what specific XlsExportOptions may be used when a report is exported to XLS.

For this example to work, you first need to add a new report (named XtraReport1) to your project, drop some report controls onto it, and then execute the code below (for instance, in the Button.Click event handler of any button on a form). Note also, that if you want the resulting file to be automatically opened in the default program which is used to open *.xls files in your system, you can call the StartProcess method, which is also shown in this example.

Imports System
Imports System.Windows.Forms
Imports System.Diagnostics
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
' ...
        Private Sub ExportToXLS()
            ' A path to export a report.
            Dim reportPath As String = "c:\Test.xls"

            ' Create a report instance.
            Dim report As New XtraReport1()

            ' Get its XLS export options.
            Dim xlsOptions As XlsExportOptions = report.ExportOptions.Xls

            ' Set XLS-specific export options.
            xlsOptions.ShowGridLines = True
            xlsOptions.TextExportMode = TextExportMode.Value

            ' Export the report to XLS.
            report.ExportToXls(reportPath)

            ' Show the result.
            StartProcess(reportPath)
        End Sub
        ' Use this method if you want to automaically open
        ' the created XLS file in the default program.
        Public Sub StartProcess(ByVal path As String)
            Dim process As New Process()
            Try
                process.StartInfo.FileName = path
                process.Start()
                process.WaitForInputIdle()
            Catch
            End Try
        End Sub
See Also