├── .babelrc ├── .eslintignore ├── .eslintrc ├── .github ├── issue_template.md └── pull_request_template.md ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── _config.yml ├── dist ├── ExcelPlugin │ ├── components │ │ └── ExcelFile.js │ ├── elements │ │ ├── ExcelColumn.js │ │ └── ExcelSheet.js │ └── utils │ │ └── DataUtil.js └── index.js ├── examples ├── simple_excel_export_01.md ├── simple_excel_export_02.md ├── styled_excel_sheet.md └── with_custom_download_element.md ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── ExcelPlugin │ ├── components │ │ └── ExcelFile.js │ ├── elements │ │ ├── ExcelColumn.js │ │ └── ExcelSheet.js │ └── utils │ │ └── DataUtil.js └── index.js ├── test ├── global.js └── unit │ ├── __snapshots__ │ └── excel.test.js.snap │ └── excel.test.js ├── types ├── index.d.ts └── types.md └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react"], 3 | "plugins": ["transform-class-properties"] 4 | } 5 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | coverage/* 3 | dist/* 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:jest/recommended" 5 | ], 6 | "root": true, 7 | "parser": "babel-eslint", 8 | "plugins": [ 9 | "jsx-a11y", 10 | "react", 11 | "jest" 12 | ], 13 | "env": { 14 | "browser": true, 15 | "commonjs": true, 16 | "es6": true, 17 | "jest": true, 18 | "node": true 19 | }, 20 | "parserOptions": { 21 | "ecmaVersion": 6, 22 | "sourceType": "module", 23 | "ecmaFeatures": { 24 | "jsx": true, 25 | "generators": true, 26 | "experimentalObjectRestSpread": true 27 | } 28 | }, 29 | "settings": { 30 | "import/ignore": [ 31 | "node_modules", 32 | "\\.(json|css|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm)$" 33 | ], 34 | "import/extensions": [ 35 | ".js" 36 | ], 37 | "import/resolver": { 38 | "node": { 39 | "extensions": [ 40 | ".js", 41 | ".json" 42 | ] 43 | } 44 | } 45 | }, 46 | "rules": { 47 | // http://eslint.org/docs/rules/ 48 | "array-callback-return": "warn", 49 | "camelcase": "warn", 50 | "curly": "warn", 51 | "default-case": [ 52 | "warn", 53 | { 54 | "commentPattern": "^no default$" 55 | } 56 | ], 57 | "dot-location": [ 58 | "warn", 59 | "property" 60 | ], 61 | "eol-last": "warn", 62 | "eqeqeq": [ 63 | "warn", 64 | "always" 65 | ], 66 | "indent": [ 67 | "warn", 68 | 4, 69 | { 70 | "SwitchCase": 1 71 | } 72 | ], 73 | "guard-for-in": "warn", 74 | "keyword-spacing": "warn", 75 | "new-parens": "warn", 76 | "no-array-constructor": "warn", 77 | "no-caller": "warn", 78 | "no-cond-assign": [ 79 | "warn", 80 | "always" 81 | ], 82 | "no-const-assign": "warn", 83 | "no-control-regex": "warn", 84 | "no-delete-var": "warn", 85 | "no-dupe-args": "warn", 86 | "no-dupe-class-members": "warn", 87 | "no-dupe-keys": "warn", 88 | "no-duplicate-case": "warn", 89 | "no-empty-character-class": "warn", 90 | "no-empty-pattern": "warn", 91 | "no-eval": "warn", 92 | "no-ex-assign": "warn", 93 | "no-extend-native": "warn", 94 | "no-extra-bind": "warn", 95 | "no-extra-label": "warn", 96 | "no-fallthrough": "warn", 97 | "no-func-assign": "warn", 98 | "no-global-assign": "warn", 99 | "no-implied-eval": "warn", 100 | "no-invalid-regexp": "warn", 101 | "no-iterator": "warn", 102 | "no-label-var": "warn", 103 | "no-labels": [ 104 | "warn", 105 | { 106 | "allowLoop": false, 107 | "allowSwitch": false 108 | } 109 | ], 110 | "no-lone-blocks": "warn", 111 | "no-loop-func": "warn", 112 | "no-mixed-operators": [ 113 | "warn", 114 | { 115 | "groups": [ 116 | [ 117 | "&", 118 | "|", 119 | "^", 120 | "~", 121 | "<<", 122 | ">>", 123 | ">>>" 124 | ], 125 | [ 126 | "==", 127 | "!=", 128 | "===", 129 | "!==", 130 | ">", 131 | ">=", 132 | "<", 133 | "<=" 134 | ], 135 | [ 136 | "&&", 137 | "||" 138 | ], 139 | [ 140 | "in", 141 | "instanceof" 142 | ] 143 | ], 144 | "allowSamePrecedence": false 145 | } 146 | ], 147 | "no-multi-str": "warn", 148 | "no-new-func": "warn", 149 | "no-new-object": "warn", 150 | "no-new-symbol": "warn", 151 | "no-new-wrappers": "warn", 152 | "no-obj-calls": "warn", 153 | "no-octal": "warn", 154 | "no-octal-escape": "warn", 155 | "no-redeclare": "warn", 156 | "no-regex-spaces": "warn", 157 | "no-restricted-syntax": [ 158 | "warn", 159 | "LabeledStatement", 160 | "WithStatement" 161 | ], 162 | "no-script-url": "warn", 163 | "no-self-assign": "warn", 164 | "no-self-compare": "warn", 165 | "no-sequences": "warn", 166 | "no-shadow-restricted-names": "warn", 167 | "no-sparse-arrays": "warn", 168 | "no-template-curly-in-string": "warn", 169 | "no-this-before-super": "warn", 170 | "no-throw-literal": "warn", 171 | "no-undef": "warn", 172 | "no-unexpected-multiline": "warn", 173 | "no-unreachable": "warn", 174 | "no-unsafe-negation": "warn", 175 | "no-unused-expressions": "warn", 176 | "no-unused-labels": "warn", 177 | "no-unused-vars": [ 178 | "warn", 179 | { 180 | "vars": "local", 181 | "args": "none" 182 | } 183 | ], 184 | "no-use-before-define": [ 185 | "warn", 186 | "nofunc" 187 | ], 188 | "no-useless-computed-key": "warn", 189 | "no-useless-concat": "warn", 190 | "no-useless-constructor": "warn", 191 | "no-useless-escape": "warn", 192 | "no-useless-rename": [ 193 | "warn", 194 | { 195 | "ignoreDestructuring": false, 196 | "ignoreImport": false, 197 | "ignoreExport": false 198 | } 199 | ], 200 | "no-with": "warn", 201 | "no-whitespace-before-property": "warn", 202 | "object-curly-spacing": [ 203 | "warn", 204 | "always" 205 | ], 206 | "operator-assignment": [ 207 | "warn", 208 | "always" 209 | ], 210 | "radix": "warn", 211 | "require-yield": "warn", 212 | "rest-spread-spacing": [ 213 | "warn", 214 | "never" 215 | ], 216 | "semi": "warn", 217 | "strict": [ 218 | "warn", 219 | "never" 220 | ], 221 | "unicode-bom": [ 222 | "warn", 223 | "never" 224 | ], 225 | "use-isnan": "warn", 226 | "valid-typeof": "warn", 227 | "react/jsx-boolean-value": "warn", 228 | "react/jsx-closing-bracket-location": "warn", 229 | "react/jsx-curly-spacing": "warn", 230 | "react/jsx-equals-spacing": [ 231 | "warn", 232 | "never" 233 | ], 234 | "react/jsx-first-prop-new-line": [ 235 | "warn", 236 | "multiline" 237 | ], 238 | "react/jsx-handler-names": "warn", 239 | "react/jsx-indent": [ 240 | "warn", 241 | 2 242 | ], 243 | "react/jsx-indent-props": [ 244 | "warn", 245 | 2 246 | ], 247 | "react/jsx-key": "warn", 248 | "react/jsx-max-props-per-line": "warn", 249 | "react/jsx-no-bind": [ 250 | "warn", 251 | { 252 | "allowArrowFunctions": true 253 | } 254 | ], 255 | "react/jsx-no-comment-textnodes": "warn", 256 | "react/jsx-no-duplicate-props": [ 257 | "warn", 258 | { 259 | "ignoreCase": true 260 | } 261 | ], 262 | "react/jsx-no-undef": "warn", 263 | "react/jsx-pascal-case": [ 264 | "warn", 265 | { 266 | "allowAllCaps": true, 267 | "ignore": [] 268 | } 269 | ], 270 | "react/jsx-sort-props": "warn", 271 | "react/jsx-tag-spacing": "warn", 272 | "react/jsx-uses-react": "warn", 273 | "react/jsx-uses-vars": "warn", 274 | "react/jsx-wrap-multilines": "warn", 275 | "react/no-deprecated": "warn", 276 | "react/no-did-mount-set-state": "warn", 277 | "react/no-did-update-set-state": "warn", 278 | "react/no-direct-mutation-state": "warn", 279 | "react/no-is-mounted": "warn", 280 | "react/no-unused-prop-types": "warn", 281 | "react/prefer-es6-class": "warn", 282 | "react/prefer-stateless-function": "warn", 283 | "react/prop-types": "warn", 284 | "react/react-in-jsx-scope": "warn", 285 | "react/require-render-return": "warn", 286 | "react/self-closing-comp": "warn", 287 | "react/sort-comp": "warn", 288 | "react/sort-prop-types": "warn", 289 | "react/style-prop-object": "warn", 290 | "react/void-dom-elements-no-children": "warn" 291 | //https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules 292 | // "jsx-a11y/aria-role": "warn", 293 | // "jsx-a11y/img-has-alt": "warn", 294 | // "jsx-a11y/img-redundant-alt": "warn", 295 | // "jsx-a11y/no-access-key": "warn" 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | 12 | 13 | #### My reason: 14 | #### Steps to reproduce: 15 | #### Lib Version: 16 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 17 | **Type:** 18 | 19 | The following has been addressed in the PR: 20 | 21 | * There is a related issue? 22 | * Unit or Functional tests are included in the PR 23 | 24 | **Description:** 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | *.log 4 | .idea/ 5 | .nyc_output/ 6 | coverage/ 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .babelrc 2 | /.nyc_output/ 3 | /coverage/ 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - '9' 5 | - '8' 6 | - '6' 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | 6 | ## [0.5.3](https://github.com/rdcalle/react-export-excel/compare/v0.5.2...v0.5.3) (2018-07-30) 7 | 8 | 9 | 10 | 11 | ## [0.5.2](https://github.com/rdcalle/react-export-excel/compare/v0.5.1...v0.5.2) (2018-07-30) 12 | 13 | 14 | 15 | 16 | ## [0.5.1](https://github.com/securedeveloper/react-data-export/compare/v0.4.2...v0.5.1) (2018-07-10) 17 | 18 | 19 | 20 | 21 | ## [0.4.2](https://github.com/securedeveloper/react-data-export/compare/v0.4.1...v0.4.2) (2018-04-24) 22 | 23 | 24 | 25 | 26 | ## [0.4.1](https://github.com/securedeveloper/react-data-export/compare/v0.4.0...v0.4.1) (2018-04-24) 27 | 28 | 29 | 30 | 31 | # [0.4.0](https://github.com/securedeveloper/react-data-export/compare/v0.3.7...v0.4.0) (2018-04-24) 32 | 33 | 34 | ### Bug Fixes 35 | 36 | * **graphite:** move to npm package ([560b2f9](https://github.com/securedeveloper/react-data-export/commit/560b2f9)), closes [issue#41](https://github.com/issue/issues/41) 37 | 38 | 39 | ### Features 40 | 41 | * add jest support ([ff3a2ba](https://github.com/securedeveloper/react-data-export/commit/ff3a2ba)) 42 | 43 | 44 | 45 | 46 | ## [0.3.7](https://github.com/securedeveloper/react-data-export/compare/v0.3.6...v0.3.7) (2018-04-04) 47 | 48 | 49 | 50 | 51 | ## [0.3.6](https://github.com/securedeveloper/react-data-export/compare/v0.3.4...v0.3.6) (2018-04-04) 52 | 53 | 54 | 55 | 56 | ## [0.3.5](https://github.com/securedeveloper/react-data-export/compare/v0.3.4...v0.3.5) (2018-04-04) 57 | 58 | 59 | 60 | 61 | ## [0.3.4](https://github.com/securedeveloper/react-data-export/compare/v0.3.3...v0.3.4) (2018-04-04) 62 | 63 | 64 | 65 | 66 | ## [0.3.3](https://github.com/securedeveloper/react-data-export/compare/v0.3.0...v0.3.3) (2018-04-02) 67 | 68 | 69 | ### Bug Fixes 70 | 71 | * package.json to reduce vulnerabilities ([cfc5ecb](https://github.com/securedeveloper/react-data-export/commit/cfc5ecb)) 72 | 73 | 74 | 75 | 76 | ## [0.3.2](https://github.com/securedeveloper/react-data-export/compare/v0.3.0...v0.3.2) (2018-04-02) 77 | 78 | 79 | ### Bug Fixes 80 | 81 | * package.json to reduce vulnerabilities ([cfc5ecb](https://github.com/securedeveloper/react-data-export/commit/cfc5ecb)) 82 | 83 | 84 | 85 | 86 | ## [0.3.1](https://github.com/securedeveloper/react-data-export/compare/v0.3.0...v0.3.1) (2017-10-20) 87 | 88 | 89 | 90 | 91 | # [0.3.0](https://github.com/securedeveloper/react-data-export/compare/v0.1.0...v0.3.0) (2017-10-20) 92 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at securedeveloper@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to react-data-export 2 | 3 | We are happy you wish to contribute this project, for that reason we want to board you with this guide. 4 | 5 | ## How I contribute? 6 | 7 | ### Generic Pull Request, e.g. code update/fix 8 | 9 | Steps that contributor should follow in order to create a pull request 10 | 11 | [Fork](https://help.github.com/articles/fork-a-repo/) the [repository](https://github.com/securedeveloper/react-export-excel) by clicking the 'Fork' icon in the top-right corner of GitHub 12 | 13 | Clone the repository in the command line on your PC: 14 | 15 | `$ git clone https://github.com/securedeveloper/react-export-excel` 16 | 17 | Navigate to the cloned repository in the OS' file manager GUI or on the command line, e.g. 18 | 19 | `$ cd react-data-export` 20 | 21 | Create a new branch to make a change on 22 | 23 | `git checkout -b new-branch` 24 | 25 | Edit the file/files that are needed for the fix/update. A simple rule of thumb is to make sure the edit is a discrete bug/piece of functionality. If it extends beyond this consider alternative branches and commits. 26 | 27 | Commit the files to the repository. Commit-ing tells the repository something has been done with the files, in this case, this is just the initial commit so we just say as much. 28 | 29 | `$ git commit -a` 30 | 31 | Your configured text editor will appear. Add your commit message (short commit messages are considered to be better): 32 | 33 | `[bugfix] Corrected behavior of application given certain parameters.` 34 | 35 | Push your changes to your repository (authentication details will appear as you do this). 36 | 37 | `$ git push` 38 | 39 | Head back to your forked GitHub repository. 40 | 41 | Click the Pull Request tab and click New Pull Request 42 | 43 | A screen will appear allowing us to review the changes we want to see adopted. We may need to select the link 'compare across forks', and from there our fork, and specific branch for the pull request. 44 | 45 | Click 'Create Pull Request' and write a description for what's in it. 46 | 47 | Submit, and wait for the original repository's owner to review the request and merge. 48 | 49 | Pull request complete. 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Afzal Ahmad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React-Export-Excel 2 | 3 | [![npm version](https://badge.fury.io/js/react-data-export.svg)](https://badge.fury.io/js/react-data-export) 4 | [![dependencies Status](https://david-dm.org/securedeveloper/react-data-export/status.svg)](https://david-dm.org/securedeveloper/react-data-export) 5 | [![devDependencies Status](https://david-dm.org/securedeveloper/react-data-export/dev-status.svg)](https://david-dm.org/securedeveloper/react-data-export?type=dev) 6 | [![Build Status](https://travis-ci.org/securedeveloper/react-data-export.svg?branch=master)](https://travis-ci.org/securedeveloper/react-data-export) 7 | [![Vulnerabilities](https://snyk.io/test/github/securedeveloper/react-data-export/badge.svg)](https://snyk.io/test/github/securedeveloper/react-data-export) 8 | [![Coverage Status](https://coveralls.io/repos/github/securedeveloper/react-data-export/badge.svg?branch=master)](https://coveralls.io/github/securedeveloper/react-data-export?branch=master) 9 | 10 | A export to excel library built with and for [React](http://facebook.github.io/react/index.html). 11 | 12 | ## Installation 13 | 14 | With [yarn](https://yarnpkg.com/en/): 15 | 16 | ```sh 17 | yarn add react-export-excel 18 | ``` 19 | 20 | With [npm](https://www.npmjs.org/package/react-export-excel): 21 | 22 | ```sh 23 | npm install react-export-excel --save 24 | ``` 25 | 26 | ## Code Examples 27 | 28 | - [Simple Excel Export](examples/simple_excel_export_01.md) 29 | - [Excel Export with Dataset](examples/simple_excel_export_02.md) 30 | - [Excel Export with Custom Download Button](examples/with_custom_download_element.md) 31 | - [Excel Export with custom cells style](examples/styled_excel_sheet.md) 32 | 33 | ## Excel Props 34 | 35 | | Prop | Type | Default | Required | Description | 36 | | :------------ | :------------------ | :--------- | :------- | :------------------------------------------------ | 37 | | hideElement | `bool` | false | `false` | To hide the button & directly download excel file | 38 | | filename | `string` | Download | `false` | Excel file name to be downloaded | 39 | | fileExtension | `string` | xlsx | `false` | Download file extension [xlsx] | 40 | | element | `HTMLElement` | `