diff --git a/src/BootstrapTable.js b/src/BootstrapTable.js index 47e060e58..770f96e36 100644 --- a/src/BootstrapTable.js +++ b/src/BootstrapTable.js @@ -1045,7 +1045,7 @@ class BootstrapTable extends Component { let result = {}; let { csvFileName } = this.props; - const { onExportToCSV, exportCSVSeparator } = this.props.options; + const { onExportToCSV, exportCSVSeparator, noAutoBOM } = this.props.options; if (onExportToCSV) { result = onExportToCSV(); } else { @@ -1073,7 +1073,7 @@ class BootstrapTable extends Component { csvFileName = csvFileName(); } - exportCSVUtil(result, keys, csvFileName, separator); + exportCSVUtil(result, keys, csvFileName, separator, noAutoBOM || true); } handleSearch = searchText => { @@ -1563,7 +1563,8 @@ BootstrapTable.propTypes = { expandBodyClass: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ]), expandParentClass: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ]), beforeShowError: PropTypes.func, - printToolBar: PropTypes.bool + printToolBar: PropTypes.bool, + noAutoBOM: PropTypes.bool }), fetchInfo: PropTypes.shape({ dataTotalSize: PropTypes.number @@ -1715,7 +1716,8 @@ BootstrapTable.defaultProps = { expandBodyClass: null, expandParentClass: null, beforeShowError: undefined, - printToolBar: true + printToolBar: true, + noAutoBOM: true }, fetchInfo: { dataTotalSize: 0 diff --git a/src/csv_export_util.js b/src/csv_export_util.js index e2ed73714..1ec5ce484 100644 --- a/src/csv_export_util.js +++ b/src/csv_export_util.js @@ -57,12 +57,12 @@ function toString(data, keys, separator) { return dataString; } -const exportCSV = function(data, keys, filename, separator) { +const exportCSV = function(data, keys, filename, separator, noAutoBOM) { const dataString = toString(data, keys, separator); if (typeof window !== 'undefined') { saveAs(new Blob([ dataString ], { type: 'text/plain;charset=utf-8' }), - filename, true); + filename, noAutoBOM); } };