From 3ba405eb627589ef4cf9ef6bb802b2ff28f7e5f1 Mon Sep 17 00:00:00 2001 From: David Ayoola Date: Wed, 9 Nov 2022 13:59:37 +0100 Subject: [PATCH 1/2] Make filetype prop none required --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5e5f2e9..996271d 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" var propTypes = { table: _propTypes2.default.string.isRequired, filename: _propTypes2.default.string.isRequired, - filetype: _propTypes2.default.string.isRequired, + filetype: _propTypes2.default.string, sheet: _propTypes2.default.string.isRequired, id: _propTypes2.default.string, className: _propTypes2.default.string, From 98ea2dda5552e910ea8872585f4f4b887f3af5fb Mon Sep 17 00:00:00 2001 From: David Ayoola Date: Wed, 9 Nov 2022 14:10:20 +0100 Subject: [PATCH 2/2] Update file type. --- src/ReactHTMLTableToExcel.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ReactHTMLTableToExcel.jsx b/src/ReactHTMLTableToExcel.jsx index fd32011..10fb418 100644 --- a/src/ReactHTMLTableToExcel.jsx +++ b/src/ReactHTMLTableToExcel.jsx @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; const propTypes = { table: PropTypes.string.isRequired, filename: PropTypes.string.isRequired, + filetype: PropTypes.string, sheet: PropTypes.string.isRequired, id: PropTypes.string, className: PropTypes.string, @@ -50,7 +51,8 @@ class ReactHTMLTableToExcel extends Component { const table = document.getElementById(this.props.table).outerHTML; const sheet = String(this.props.sheet); - const filename = `${String(this.props.filename)}.xls`; + const filetype = String((this.props.filetype)?(this.props.filetype === 'xlsx'?'xlsx':'xls'):'xls') + const filename = String(this.props.filename) + '.' + filetype; const uri = 'data:application/vnd.ms-excel;base64,'; const template =