Skip to main content
A newer version of this page is available. .

Export

  • 3 minutes to read

Run Demo

The ASPxTreeList allows you to export data in PDF, XLS, XLSX, RTF and DOCX formats.

Set the EnableClientSideExportAPI property to true to enable the toolbar export commands and client export API.

<dx:ASPxTreeList runat="server" ID="TList">
    <SettingsExport EnableClientSideExportAPI="True" />
</dx:ASPxTreeList>

Export in UI

Toolbar

Add a TreeListToolbarItem object and set its Command property to one of the following values:

<dx:ASPxTreeList ID="treeList" >
    <Toolbars>
        <dx:TreeListToolbar>
            <Items>
                <dx:TreeListToolbarItem Command="ExportToPdf" />
                <dx:TreeListToolbarItem Command="ExportToXls" />
                <dx:TreeListToolbarItem Command="ExportToXlsx" />
                <dx:TreeListToolbarItem Command="ExportToDocx" />
                <dx:TreeListToolbarItem Command="ExportToRtf" />
            </Items>
        </dx:TreeListToolbar>
    </Toolbars>
</dx:ASPxTreeList>

Custom UI Element

Add a custom UI element (for example, ASPxButton) and use export API in the element’s click handler.

<dx:ASPxButton runat="server" ID="Btn" Text="Export" OnClick="btn_Click">
</dx:ASPxButton>

<dx:ASPxTreeList runat="server" ID="TList">
</dx:ASPxTreeList>
protected void btn_Click(object sender, EventArgs e) {
    TList.ExportRtfToResponse();
}

Tree List Exporter

Create an instance of the ASPxTreeListExporter object, set its TreeListID property and call the method that corresponds to the format of the exported tree list data.

// Built-In Export
<dx:ASPxTreeList runat="server" ID="TList">
    <StylesExport>
        <Header BackColor="Yellow" />
        <Footer BackColor="Yellow" />
    </StylesExport>
</dx:ASPxTreeList>

// Tree List Exporter
<dx:ASPxTreeListExporter runat="server" ID="TListExporter">
    <Styles>
        <Header BackColor="Yellow" />
        <Footer BackColor="Yellow" />
    </Styles>
</dx:ASPxTreeListExporter>
TListExporter.WriteXlsToResponse("test.xls", true); 

Related Events:

  • BeforeExport - Occurs before the tree list data is exported.

  • RenderBrick - Allows you to render any part of the exported data.

Export in Code

Client API

Call the ExportTo(format) method and pass the export format (ASPxClientTreeListExportFormat) to this method.

<dx:ASPxTreeList runat="server" ID="TList" ClientInstanceName="treeList">
    <SettingsExport EnableClientSideExportAPI="True" />
</dx:ASPxTreeList>
treeList.ExportTo(ASPxClientTreeListExportFormat.Xls);

Server API

You can call any of the following methods to export tree list data on the server:

<dx:ASPxTreeList runat="server" ID="TList" >
</dx:ASPxTreeList>
TList.ExportPdfToResponse();
TList.ExportDocxToResponse();
TList.ExportRtfToResponse();
TList.ExportXlsToResponse();
TList.ExportXlsxToResponse();

Related Events:

Appearance

Use the StylesExport property (for the built-in export) or the Styles property (for the Tree List Exporter) to customize the appearance of the exported document.

// Built-In Export
<dx:ASPxTreeList runat="server" ID="TList">
    <StylesExport>
        <Header BackColor="Yellow" />
        <Footer BackColor="Yellow" />
    </StylesExport>
</dx:ASPxTreeList>

// Tree List Exporter
<dx:ASPxTreeListExporter runat="server" ID="TListExporter">
    <Styles>
        <Header BackColor="Yellow" />
        <Footer BackColor="Yellow" />
    </Styles>
</dx:ASPxTreeListExporter>

Limitations

  • The Data-Aware export is not supported.

  • The ASPxTreeListExporter does not export the content of template columns and hidden data columns.

Note

DevExpress controls require the DevExpress.RichEdit.v20.2.Export.dll library to export their content to DOCX or RTF format.