react-bootstrap-table / react-bootstrap-table2

Next Generation of react-bootstrap-table
https://react-bootstrap-table.github.io/react-bootstrap-table2/
MIT License
1.27k stars 431 forks source link

How to export Utf-8 with BOM charset #1816

Closed XamBoy closed 9 months ago

XamBoy commented 9 months ago

Please give the code to export table data with UTF-8 with BOM encoding

XamBoy commented 9 months ago

I add '\uFEFF' at transform func() for this code.

react-bootstrap-table2-toolkit/lib/src/csv/exporter.js var transform = exports.transform = function transform(data, meta, columns, _, _ref) { var separator = _ref.separator, ignoreHeader = _ref.ignoreHeader, ignoreFooter = _ref.ignoreFooter;

var visibleColumns = meta.filter(function (m) { return m.export; }); var content = '\uFEFF'; <================This // extract csv header if (!ignoreHeader) { content += visibleColumns.map(function (m) { return '"' + m.header + '"'; }).join(separator); content += '\n'; } the data is correct for excel. Please consider about this.

XamBoy commented 9 months ago

Its fixed NOW