Ticket T610452
Visible to All Users

DataGrid - Export to Excel creates empty file only with column names

created 7 years ago (modified 7 years ago)

Hello,

I'm using Data Grid component in angular 5 project. When i click on 'export data' option, excel file is created but without data, only with column names.

I use odata store type to fetch data. On each filter and page change, request is send to server to fetch data. Here is how dataSource property of the data grid is set:


    this.dataSource == {
            store: {
                type: "odata",
                version: 4,
                url: this.actionUrl + "userLogins/getAll",
                onLoading(loadOptions) {
                    loptions = loadOptions.filter ? loadOptions.filter : "";
                },
                beforeSend(xhr) {
                    xhr.headers["Content-Type"] = "application/x-www-form-urlencoded";
                    xhr.headers["Accept"] = "application/json";
                    xhr.headers["LanguageCulture"] = hed.headersLanguage;
                    xhr.headers["Authorization"] = "Bearer " + hed.authService.getUser().access_token;
                    if (loptions)
                        xhr.params["$filter1"] = JSON.stringify(loptions);
                },
            },
            select: [
                "UserTimeOfAction",
                "UserName",
                "ApplicationName",
                "ClientId",
                "UserAction"
            ],
        };

Can you tell me if i'm missing something?

Thank you,
Ivancho

Answers approved by DevExpress Support

created 7 years ago (modified 7 years ago)

Hi,

Please check to see if this issue is similar to the one mentioned in the T585515: dxDataGrid - xslx file is empty after export ticket that gives possible solutions. If this does not help you, isolate the issue into a runnable code example and post it here for further research. Thank you for your time and cooperation in advance.

Thanks,
Alessandro

    Show previous comments (5)
    DevExpress Support Team 7 years ago

      Hi Ivanco,

      I've run your plunk, but it has compilation errors and sends incorrect requests to our OData service. After I corrected the errors, I can see data in the grid and in an exported Excel file. I've attached a screencast to illustrate this. Here is my updated plunk. Would you please modify it so that it will be runnable and reproduces the issue?

      IG IG
      Ivancho Gjeorgjiev 7 years ago

        Hello Gosha,

        Thank you very much for your time and effort .

        The problem was on the server side:
        In case of exporting data to excel, the request to the server contains 'Top' property (number of records to be returned for the selected page of the grid) that has 0 as a value and the API didn't have logic to handle this case.

        We added this logic to our API and now all works as it should.

        Many thanks,
        Ivanco

        DevExpress Support Team 7 years ago

          It's great to hear that the issue has been resolved, Ivanco. Feel free to contact us in case of any difficulties.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.