Skip to content

Commit 1ffc604

Browse files
committed
New feature for text encoding added
New feature for text encoding added * Added feature to specify the data encoding. Via `encoding` prop. By Default, the encoding is UTF-8 if prop is not passed. Otherwise it can be passed the data encoding wished for the text. Signed-off-by: Jose Antonio Ciccio <jciccio@gmail.com>
1 parent 08a0e14 commit 1ffc604

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Changes the background to white and the text to blue
138138
| ------------- |:-------------:| -----:|:-----|
139139
| content | object | Y |Contents to display on tables |
140140
| headers | array (String) | Y | Array of strings, these will be used to choose what to show in the table |
141+
| encoding | String |N| Data encoding for table and file, UTF-8 by default |
141142
| minHeight | integer | Y| Min table desired height |
142143
| maxHeight | integer |Y | Max table desired height |
143144
| activateDownloadButton | boolean |Y | Activates download button |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-js-table-with-csv-dl",
3-
"version": "0.5.8",
3+
"version": "0.6.0",
44
"description": "React JS tables and log viewer with stats if needed. Has the functionality to dowload table contents in CSV file with data stored in class prop.",
55
"main": "build/index.js",
66
"peerDependencies": {

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class TableViewer extends Component {
8282
}
8383

8484
generateAndDownloadCSV() {
85-
let csvType = {encoding:"UTF-8",type:"text/plain;charset=UTF-8"};
85+
86+
let encoding = this.props.encoding ? this.props.encoding : "UTF-8";
87+
let csvType = {encoding:encoding,type:"text/plain;charset="+encoding};
8688
let filename = this.props.filename? this.props.filename : "logResults.csv";
8789
var csvContent = "";
8890
var data = this.props.content;
@@ -429,7 +431,8 @@ TableViewer.propTypes = {
429431
activePageBoxStyle:PropTypes.object,
430432
maxPagesToDisplay: PropTypes.number,
431433
downloadButtonStyle:PropTypes.object,
432-
sortColumn:PropTypes.string
434+
sortColumn:PropTypes.string,
435+
encoding:PropTypes.string
433436
};
434437

435438
export default TableViewer;

0 commit comments

Comments
 (0)