Skip to content

Commit 064f1e4

Browse files
Merge branch 'master' into fix-int-cells-in-dataSet
2 parents 513ae48 + 7c0baae commit 064f1e4

File tree

10 files changed

+4359
-7786
lines changed

10 files changed

+4359
-7786
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sudo: false
22
language: node_js
33
node_js:
4+
- '10'
45
- '9'
56
- '8'
6-
- '6'

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# React-Data-Export
22

3+
##### :warning: A complete re-write is coming soon (we won't need xlsx package anymore (It will be backward compatible):warning:
4+
5+
## :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)
6+
(: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)
7+
38
[![npm version](https://badge.fury.io/js/react-data-export.svg)](https://badge.fury.io/js/react-data-export)
49
[![dependencies Status](https://david-dm.org/securedeveloper/react-data-export/status.svg)](https://david-dm.org/securedeveloper/react-data-export)
510
[![devDependencies Status](https://david-dm.org/securedeveloper/react-data-export/dev-status.svg)](https://david-dm.org/securedeveloper/react-data-export?type=dev)

dist/ExcelPlugin/utils/DataUtil.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,26 @@ var excelSheetFromDataSet = function excelSheetFromDataSet(dataSet) {
6464

6565
rowCount += ySteps;
6666

67+
var columnsWidth = [];
6768
if (columns.length >= 0) {
6869
columns.forEach(function (col, index) {
6970
var cellRef = _xlsx2.default.utils.encode_cell({ c: xSteps + index, r: rowCount });
7071
fixRange(range, 0, 0, rowCount, xSteps, ySteps);
71-
getHeaderCell(col, cellRef, ws);
72+
var colTitle = col;
73+
if ((typeof col === 'undefined' ? 'undefined' : _typeof(col)) === 'object') {
74+
colTitle = col.title;
75+
columnsWidth.push(col.width || { wpx: 80 }); /* wch (chars), wpx (pixels) - e.g. [{wch:6},{wpx:50}] */
76+
}
77+
getHeaderCell(colTitle, cellRef, ws);
7278
});
7379

7480
rowCount += 1;
7581
}
7682

83+
if (columnsWidth.length > 0) {
84+
ws['!cols'] = columnsWidth;
85+
}
86+
7787
for (var R = 0; R != data.length; ++R, rowCount++) {
7888
for (var C = 0; C != data[R].length; ++C) {
7989
var cellRef = _xlsx2.default.utils.encode_cell({ c: C + xSteps, r: rowCount });

examples/styled_excel_sheet.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const ExcelSheet = ReactExport.ExcelFile.ExcelSheet;
88

99
const multiDataSet = [
1010
{
11-
columns: ["Headings", "Text Style", "Colors"],
11+
columns: [
12+
{title: "Headings", width: {wpx: 80}},//pixels width
13+
{title: "Text Style", width: {wch: 40}},//char width
14+
{title: "Colors", width: {wpx: 90}},
15+
],
1216
data: [
1317
[
1418
{value: "H1", style: {font: {sz: "24", bold: true}}},

jest.config.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
module.exports = {
2-
name: 'react-data-export-jest',
3-
verbose: true,
4-
collectCoverage: true,
5-
coveragePathIgnorePatterns: [
6-
'node_modules',
7-
],
8-
testEnvironment: 'jest-environment-jsdom-global',
9-
testRegex: '(/test/unit.*\\.test)\\.js',
10-
setupFiles: [
11-
'./test/global.js'
12-
],
13-
modulePathIgnorePatterns: [
14-
'global.js'
15-
],
16-
testPathIgnorePatterns: [
17-
'__snapshots__'
18-
]
2+
name: 'react-data-export-jest',
3+
verbose: true,
4+
collectCoverage: true,
5+
coveragePathIgnorePatterns: [
6+
'node_modules',
7+
],
8+
testEnvironment: 'node',
9+
testRegex: '(/test/unit.*\\.test)\\.js',
10+
setupFiles: [
11+
'./test/global.js'
12+
],
13+
modulePathIgnorePatterns: [
14+
'global.js'
15+
],
16+
testPathIgnorePatterns: [
17+
'__snapshots__'
18+
]
1919
};

0 commit comments

Comments
 (0)