428
Views
7
Comments
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

2024-03-25 06-19-08
Harlin Setiadarma

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

Have you ticked the columns you want to include?

2018-05-16 11-16-36
João Heleno
 
MVP

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

2023-02-10 10-15-37
Pradeep Dubey

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.



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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?

2023-02-10 10-15-37
Pradeep Dubey

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'
                ]
            }
        ]

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Thanks for the explanation!

2023-02-10 10-15-37
Pradeep Dubey

Your welcome :-)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.