DataTables export to excel file

  

Good afternoon people,


I'm building a data table, and I want to download it to some formats (PDF, CSV, Excel), and all work except Excel. I can download excel (.xlsx), and the file have content, however with I'm going to open it, it returns me this error message: excel can not open the file because the file format or file extension is not valid.


Anyone had this problem? How did you build JavaScript?


Thank you,

Miguel

Did you use RecordListToExcel built-in action from left panel?

Have you ticked the columns you want to include?

Hi Miguel,

Are you using the default mime type when downloading?

Have you tried "application/vnd.ms-excel" or "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" instead?


Regards,

JH

Nuno Miguel da C Fernandes Verdasca wrote:

Good afternoon people,


I'm building a data table, and I want to download it to some formats (PDF, CSV, Excel), and all work except Excel. I can download excel (.xlsx), and the file have content, however with I'm going to open it, it returns me this error message: excel can not open the file because the file format or file extension is not valid.


Anyone had this problem? How did you build JavaScript?


Thank you,

Miguel

Hello Nuno, 

Please share your oml. I had the same problem earlier. Now it is working properly.

Thanks,

Pradeep.



Pradeep,

The post is already a few months old, I think Nuno has solved it as well :). However, perhaps you can tell us what you did to solve it? What was the problem in your case?

Kilian Hekhuis wrote:

Pradeep,

The post is already a few months old, I think Nuno has solved it as well :). However, perhaps you can tell us what you did to solve it? What was the problem in your case?

Sure Kilian,

I had problems to export datatable into excel, pdf and csv. I've added and customized Export Button using button json object like below and passed copy,excel,csv,pdf and print options into 'button' JavaScript array.

"buttons": [
            {
                extend: 'collection',
                text: 'Export',
                buttons: [
                    'copy',
                    'excel',
                    'csv',
                    'pdf',
                    'print'
                ]
            }
        ]

Thanks for the explanation!

Your welcome :-)