react-data-export
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -0,0 +0,0 @@ <!-- |
@@ -0,0 +0,0 @@ <!-- |
@@ -5,2 +5,22 @@ # Change Log | ||
<a name="0.5.0"></a> | ||
# [0.5.0](https://github.com/securedeveloper/react-data-export/compare/v0.4.2...v0.5.0) (2018-09-24) | ||
### Bug Fixes | ||
* Fixed[#41](https://github.com/securedeveloper/react-data-export/issues/41), Fixed[#55](https://github.com/securedeveloper/react-data-export/issues/55), Fixed[#66](https://github.com/securedeveloper/react-data-export/issues/66), Fixed[#67](https://github.com/securedeveloper/react-data-export/issues/67), Fixed[#68](https://github.com/securedeveloper/react-data-export/issues/68), Fixed[#69](https://github.com/securedeveloper/react-data-export/issues/69), Fixed[#72](https://github.com/securedeveloper/react-data-export/issues/72) ([0144afc](https://github.com/securedeveloper/react-data-export/commit/0144afc)) | ||
* int cells were not supported in dataSet format ([513ae48](https://github.com/securedeveloper/react-data-export/commit/513ae48)) | ||
* package vulnerabilities. ([082947a](https://github.com/securedeveloper/react-data-export/commit/082947a)) | ||
* package vulnerabilities. ([d66eb9e](https://github.com/securedeveloper/react-data-export/commit/d66eb9e)) | ||
* updated package to tempa-xlsx, updated jest test environment and imports. ([b4f03ac](https://github.com/securedeveloper/react-data-export/commit/b4f03ac)) | ||
### Features | ||
* support col width ([dc6dc60](https://github.com/securedeveloper/react-data-export/commit/dc6dc60)) | ||
* update example with col widths ([4863aaf](https://github.com/securedeveloper/react-data-export/commit/4863aaf)) | ||
<a name="0.4.2"></a> | ||
@@ -7,0 +27,0 @@ ## [0.4.2](https://github.com/securedeveloper/react-data-export/compare/v0.4.1...v0.4.2) (2018-04-24) |
@@ -0,0 +0,0 @@ # Contributor Covenant Code of Conduct |
@@ -0,0 +0,0 @@ # Contributing to react-data-export |
@@ -19,5 +19,5 @@ "use strict"; | ||
var _xlsx = require("xlsx"); | ||
var _tempaXlsx = require("tempa-xlsx"); | ||
var _xlsx2 = _interopRequireDefault(_xlsx); | ||
var _tempaXlsx2 = _interopRequireDefault(_tempaXlsx); | ||
@@ -105,3 +105,3 @@ var _ExcelSheet = require("../elements/ExcelSheet"); | ||
var fileName = this.getFileName(); | ||
var wbout = _xlsx2.default.write(wb, { bookType: fileExtension, bookSST: true, type: 'binary' }); | ||
var wbout = _tempaXlsx2.default.write(wb, { bookType: fileExtension, bookSST: true, type: 'binary' }); | ||
@@ -108,0 +108,0 @@ (0, _fileSaver.saveAs)(new Blob([(0, _DataUtil.strToArrBuffer)(wbout)], { type: "application/octet-stream" }), fileName); |
@@ -10,5 +10,5 @@ 'use strict'; | ||
var _xlsx = require('xlsx'); | ||
var _tempaXlsx = require('tempa-xlsx'); | ||
var _xlsx2 = _interopRequireDefault(_xlsx); | ||
var _tempaXlsx2 = _interopRequireDefault(_tempaXlsx); | ||
@@ -68,7 +68,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var columnsWidth = []; | ||
if (columns.length >= 0) { | ||
columns.forEach(function (col, index) { | ||
var cellRef = _xlsx2.default.utils.encode_cell({ c: xSteps + index, r: rowCount }); | ||
var cellRef = _tempaXlsx2.default.utils.encode_cell({ c: xSteps + index, r: rowCount }); | ||
fixRange(range, 0, 0, rowCount, xSteps, ySteps); | ||
getHeaderCell(col, cellRef, ws); | ||
var colTitle = col; | ||
if ((typeof col === 'undefined' ? 'undefined' : _typeof(col)) === 'object') { | ||
colTitle = col.title; | ||
columnsWidth.push(col.width || { wpx: 80 }); /* wch (chars), wpx (pixels) - e.g. [{wch:6},{wpx:50}] */ | ||
} | ||
getHeaderCell(colTitle, cellRef, ws); | ||
}); | ||
@@ -79,5 +85,9 @@ | ||
if (columnsWidth.length > 0) { | ||
ws['!cols'] = columnsWidth; | ||
} | ||
for (var R = 0; R != data.length; ++R, rowCount++) { | ||
for (var C = 0; C != data[R].length; ++C) { | ||
var cellRef = _xlsx2.default.utils.encode_cell({ c: C + xSteps, r: rowCount }); | ||
var cellRef = _tempaXlsx2.default.utils.encode_cell({ c: C + xSteps, r: rowCount }); | ||
fixRange(range, R, C, rowCount, xSteps, ySteps); | ||
@@ -90,3 +100,3 @@ getCell(data[R][C], cellRef, ws); | ||
if (range.s.c < 10000000) { | ||
ws['!ref'] = _xlsx2.default.utils.encode_range(range); | ||
ws['!ref'] = _tempaXlsx2.default.utils.encode_range(range); | ||
} | ||
@@ -107,21 +117,24 @@ | ||
function getCell(v, cellRef, ws) { | ||
var cell = {}; | ||
//assume v is indeed the value. for other cases (object, date...) it will be overriden. | ||
var cell = { v: v }; | ||
if (v === null) { | ||
return; | ||
} | ||
var isDate = v instanceof Date; | ||
if (!isDate && (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') { | ||
cell.s = v.style; | ||
cell.v = v.value; | ||
v = v.value; | ||
} | ||
if (typeof v === 'number') { | ||
cell.v = v; | ||
cell.t = 'n'; | ||
} else if (typeof v === 'boolean') { | ||
cell.v = v; | ||
cell.t = 'b'; | ||
} else if (v instanceof Date) { | ||
} else if (isDate) { | ||
cell.t = 'n'; | ||
cell.z = _xlsx2.default.SSF._table[14]; | ||
cell.z = _tempaXlsx2.default.SSF._table[14]; | ||
cell.v = dateToNumber(cell.v); | ||
} else if ((typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') { | ||
cell.v = v.value; | ||
cell.s = v.style; | ||
} else { | ||
cell.v = v; | ||
cell.t = 's'; | ||
@@ -177,3 +190,3 @@ } | ||
var cellRef = _xlsx2.default.utils.encode_cell({ c: C, r: R }); | ||
var cellRef = _tempaXlsx2.default.utils.encode_cell({ c: C, r: R }); | ||
if (typeof cell.v === 'number') { | ||
@@ -185,3 +198,3 @@ cell.t = 'n'; | ||
cell.t = 'n'; | ||
cell.z = _xlsx2.default.SSF._table[14]; | ||
cell.z = _tempaXlsx2.default.SSF._table[14]; | ||
cell.v = dateToNumber(cell.v); | ||
@@ -197,3 +210,3 @@ } else { | ||
if (range.s.c < 10000000) { | ||
ws['!ref'] = _xlsx2.default.utils.encode_range(range); | ||
ws['!ref'] = _tempaXlsx2.default.utils.encode_range(range); | ||
} | ||
@@ -200,0 +213,0 @@ |
@@ -38,3 +38,3 @@ ## Simple Excel Export | ||
var dataSet2 = [ | ||
const dataSet2 = [ | ||
{ | ||
@@ -41,0 +41,0 @@ name: "Johnson", |
@@ -0,0 +0,0 @@ ```javascript |
@@ -11,3 +11,7 @@ ```javascript | ||
{ | ||
columns: ["Headings", "Text Style", "Colors"], | ||
columns: [ | ||
{title: "Headings", width: {wpx: 80}},//pixels width | ||
{title: "Text Style", width: {wch: 40}},//char width | ||
{title: "Colors", width: {wpx: 90}}, | ||
], | ||
data: [ | ||
@@ -14,0 +18,0 @@ [ |
@@ -0,0 +0,0 @@ ```javascript |
module.exports = { | ||
name: 'react-data-export-jest', | ||
verbose: true, | ||
collectCoverage: true, | ||
coveragePathIgnorePatterns: [ | ||
'node_modules', | ||
], | ||
testEnvironment: 'jest-environment-jsdom-global', | ||
testRegex: '(/test/unit.*\\.test)\\.js', | ||
setupFiles: [ | ||
'./test/global.js' | ||
], | ||
modulePathIgnorePatterns: [ | ||
'global.js' | ||
], | ||
testPathIgnorePatterns: [ | ||
'__snapshots__' | ||
] | ||
name: 'react-data-export-jest', | ||
verbose: true, | ||
collectCoverage: true, | ||
coveragePathIgnorePatterns: [ | ||
'node_modules', | ||
], | ||
testEnvironment: 'node', | ||
testRegex: '(/test/unit.*\\.test)\\.js', | ||
setupFiles: [ | ||
'./test/global.js' | ||
], | ||
modulePathIgnorePatterns: [ | ||
'global.js' | ||
], | ||
testPathIgnorePatterns: [ | ||
'__snapshots__' | ||
] | ||
}; |
{ | ||
"name": "react-data-export", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"main": "dist/index.js", | ||
@@ -24,3 +24,3 @@ "description": "A set of tools to export dataset from react to different formats.", | ||
"file-saver": "1.3.3", | ||
"xlsx": "git+https://github.com/securedeveloper/js-xlsx.git" | ||
"tempa-xlsx": "0.0.1" | ||
}, | ||
@@ -31,5 +31,5 @@ "devDependencies": { | ||
"babel-cli": "6.26.0", | ||
"babel-core": "6.26.0", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "8.0.1", | ||
"babel-jest": "22.4.1", | ||
"babel-eslint": "8.0.1", | ||
"babel-plugin-transform-class-properties": "6.24.1", | ||
@@ -40,20 +40,19 @@ "babel-preset-es2015": "6.24.1", | ||
"cross-env": "5.1.0", | ||
"husky": "0.15.0-rc.13", | ||
"enzyme": "3.3.0", | ||
"enzyme-adapter-react-16": "1.1.1", | ||
"enzyme": "^3.6.0", | ||
"enzyme-adapter-react-16": "^1.5.0", | ||
"eslint": "4.8.0", | ||
"eslint-plugin-import": "2.7.0", | ||
"eslint-plugin-jest": "21.14.0", | ||
"eslint-plugin-jsx-a11y": "6.0.2", | ||
"eslint-plugin-jest": "21.14.0", | ||
"eslint-plugin-react": "7.4.0", | ||
"eslint-watch": "3.1.3", | ||
"husky": "0.15.0-rc.13", | ||
"jest": "^23.6.0", | ||
"jest-environment-node": "22.4.1", | ||
"nyc": "11.2.1", | ||
"jest": "22.4.2", | ||
"jest-environment-jsdom": "22.4.1", | ||
"jest-environment-jsdom-global": "1.0.3", | ||
"jest-environment-node": "22.4.1", | ||
"prop-types": "15.6.0", | ||
"react": "16.0.0", | ||
"react-dom": "16.0.0", | ||
"standard-version": "4.2.0" | ||
"standard-version": "^4.4.0", | ||
"xlsx": "^0.14.0" | ||
}, | ||
@@ -60,0 +59,0 @@ "scripts": { |
# React-Data-Export | ||
##### :warning: A complete re-write is coming soon (we won't need xlsx package anymore (It will be backward compatible):warning: | ||
## :new: I am re-writing complete excel api in JavaScript, please consider contributing or putting your ideas here https://github.com/securedeveloper/javascript-excel (After finishing will update this library) | ||
(:exclamation::exclamation::exclamation:The purpose of having a new library is that open source libraries either does not support styling and rest functionality in excel or they are too heavy to consider) | ||
[![npm version](https://badge.fury.io/js/react-data-export.svg)](https://badge.fury.io/js/react-data-export) | ||
@@ -4,0 +9,0 @@ [![dependencies Status](https://david-dm.org/securedeveloper/react-data-export/status.svg)](https://david-dm.org/securedeveloper/react-data-export) |
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import {saveAs} from "file-saver"; | ||
import XLSX from "xlsx"; | ||
import XLSX from "tempa-xlsx"; | ||
@@ -6,0 +6,0 @@ import ExcelSheet from "../elements/ExcelSheet"; |
@@ -0,0 +0,0 @@ import React from "react"; |
@@ -0,0 +0,0 @@ import React from "react"; |
@@ -1,2 +0,2 @@ | ||
import XLSX from "xlsx"; | ||
import XLSX from "tempa-xlsx"; | ||
@@ -54,2 +54,3 @@ const strToArrBuffer = (s) => { | ||
var columnsWidth = [] | ||
if (columns.length >= 0) { | ||
@@ -59,3 +60,8 @@ columns.forEach((col, index) => { | ||
fixRange(range, 0, 0, rowCount, xSteps, ySteps); | ||
getHeaderCell(col, cellRef, ws); | ||
var colTitle = col; | ||
if (typeof col === 'object'){ | ||
colTitle = col.title; | ||
columnsWidth.push(col.width || {wpx:80}); /* wch (chars), wpx (pixels) - e.g. [{wch:6},{wpx:50}] */ | ||
} | ||
getHeaderCell(colTitle, cellRef, ws); | ||
}); | ||
@@ -66,2 +72,6 @@ | ||
if (columnsWidth.length > 0){ | ||
ws['!cols'] = columnsWidth; | ||
} | ||
for (var R = 0; R != data.length; ++R, rowCount++) { | ||
@@ -93,21 +103,25 @@ for (var C = 0; C != data[R].length; ++C) { | ||
function getCell(v, cellRef, ws) { | ||
var cell = {}; | ||
//assume v is indeed the value. for other cases (object, date...) it will be overriden. | ||
var cell = {v}; | ||
if (v === null) { | ||
return; | ||
} | ||
var isDate = (v instanceof Date); | ||
if (!isDate && (typeof v === 'object')) { | ||
cell.s = v.style; | ||
cell.v = v.value; | ||
v = v.value; | ||
} | ||
if (typeof v === 'number') { | ||
cell.v = v; | ||
cell.t = 'n'; | ||
} else if (typeof v === 'boolean') { | ||
cell.v = v; | ||
cell.t = 'b'; | ||
} else if (v instanceof Date) { | ||
} else if (isDate) { | ||
cell.t = 'n'; | ||
cell.z = XLSX.SSF._table[14]; | ||
cell.v = dateToNumber(cell.v); | ||
} else if (typeof v === 'object') { | ||
cell.v = v.value; | ||
cell.s = v.style; | ||
} else { | ||
cell.v = v; | ||
cell.t = 's'; | ||
@@ -114,0 +128,0 @@ } |
@@ -0,0 +0,0 @@ import ExcelFile from "./ExcelPlugin/components/ExcelFile"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ /* index.d.ts (C) react-data-export */ |
@@ -0,0 +0,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
28
38
875
143
0
95415
+ Addedtempa-xlsx@0.0.1
+ Addedadler-32@1.3.1(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcfb@1.2.2(transitive)
+ Addedcodepage@1.3.8(transitive)
+ Addedcolors@0.6.2(transitive)
+ Addedcommander@13.1.0(transitive)
+ Addedconcat-stream@2.0.0(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addedfrac@0.3.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjszip@2.4.0(transitive)
+ Addedpako@0.2.9(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedssf@0.8.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtempa-xlsx@0.0.1(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedvoc@1.2.0(transitive)
- Removedxlsx@git+https://github.com/securedeveloper/js-xlsx.git