Skip to content

Commit

Permalink
IE Array.fill replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Aug 2, 2016
1 parent d60210b commit 1b94acc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 37 deletions.
35 changes: 14 additions & 21 deletions dist/table2excel.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"dependencies": {
"filesaver.js": "^0.2.0",
"object-assign": "^4.1.0",
"xlsx-style": "^0.8.13"
"xlsx": "^0.8.0"
}
}
3 changes: 0 additions & 3 deletions src/helpers/cell-to-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ export default function cellToObject(cell, typeHandlers) {
// default handler
if (!cellObject) cellObject = { t: 's', v: text };

// styling
if (cell.tagName === 'TH') cellObject.s = { font: { bold: true } };

return cellObject;
}
2 changes: 1 addition & 1 deletion src/helpers/data-to-worksheet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import XLSX from 'xlsx-style';
import XLSX from 'xlsx';

import cellToObject from './cell-to-object';

Expand Down
8 changes: 2 additions & 6 deletions src/helpers/table-to-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export default function tableToData(table) {
cells[rowIndex].length <= range.e.c
) {
// ... fill the cells with empty values
Array(range.e.c - range.s.c + 1).fill(0).forEach(() => {
cells[rowIndex].push(null);
});
for (let i = range.s.c; i < range.e.c; i++) cells[rowIndex].push(null);
}
});

Expand All @@ -56,9 +54,7 @@ export default function tableToData(table) {

// if we are in a following colspan ...
if (colspan > 1) {
Array(colspan - 1).fill(0).forEach(() => {
cells[rowIndex].push(null);
});
for (let i = 1; i < colspan; i++) cells[rowIndex].push(null);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import XLSX from 'xlsx-style';
import XLSX from 'xlsx';
import { saveAs } from 'filesaver.js';

import tableToData from './helpers/table-to-data';
Expand Down
4 changes: 0 additions & 4 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export default {
loader: 'babel-loader',
exclude: /node_modules/,
},
/*{
test: /\.min\.js$/,
loader: 'script',
},*/
],
},
plugins: [
Expand Down

0 comments on commit 1b94acc

Please sign in to comment.