react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

CSV export resulting in error for .xlsx

Open g-akshay opened this issue 6 years ago • 3 comments

Getting the following error when trying to use .xlsx extension.

Excel cannot open the file 'ManageRides (1).xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

I am using the following code: (commented ones are also being tried) exportCSV={{ fileName: 'filename.xlsx', blobType: "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8" //blobType: "data:text/csv;charset=utf-8" //blobType: "data:text/csv;charset=UTF-8,%EF%BB%BFs" }}

Screenshots image

On using the .xls extension, whole row data is shown in the first cell and no column segregation happens.

image image

Whats blobType is supported for .xls or .xlsx extension?

g-akshay avatar Feb 10 '20 10:02 g-akshay

actually, I'm not sure about this answer, we used file-saver to save file and they just provide a way to customize the blob type. I think you have to ask this question in their repository https://github.com/eligrey/FileSaver.js/ .

You can open another issue if they or you still think this issue is about react-bootstrap-table2

AllenFang avatar Feb 11 '20 13:02 AllenFang

@g-akshay I have the same issue. How did you solve it?

malsioufi avatar Jun 01 '20 08:06 malsioufi

@g-akshay @malsioufi I have applied some changes in react-bootstrap-table2-toolkit to export in xlsx, it works perfectly. I hope it will be of help to those who need to use the format #1666

fjperini avatar Aug 10 '21 17:08 fjperini