Skip to content

Commit 07af7a5

Browse files
committed
Native JS is package main, tidied up test code
1 parent d7b2a00 commit 07af7a5

File tree

124 files changed

+1117
-1307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1117
-1307
lines changed

README.md

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,24 @@ npm install exceljs
1818

1919
# New Features!
2020

21-
**Major Version Change**
21+
** Another Major Version Change**
2222

23-
Introducing async/await to ExcelJS!
24-
The new async and await features of JavaScript can help a lot to make code more readable and maintainable.
25-
To avoid confusion, particularly with returned promises from async functions, we have had to remove the
26-
Promise class configuration option and from v2 onwards ExcelJS will use native Promises.
27-
Since this is potentially a breaking change we're bumping the major version for this release.
23+
Javascript has changed a lot over the years, and so have the modules and technologies surrounding it.
24+
To this end, this major version of ExcelJS changes the structure of the publish artefacts:
2825

29-
**Changes**
26+
** Main Export is now the Original Javascript Source **
3027

31-
<ul>
32-
<li>
33-
Merged <a href="https://github.com/exceljs/exceljs/pull/829">Introduce async/await #829</a>.
34-
Many thanks to <a href="https://github.com/alubbe">Andreas Lubbe</a> for this contribution.
35-
</li>
36-
<li>
37-
Merged <a href="https://github.com/exceljs/exceljs/pull/930">Update index.d.ts #930</a>.
38-
Many thanks to <a href="https://github.com/cosmonovallc">cosmonovallc</a> for this contributions.
39-
</li>
40-
<li>
41-
Merged <a href="https://github.com/exceljs/exceljs/pull/940">TS: Add types for addTable function #940</a>.
42-
Many thanks to <a href="https://github.com/egmen">egmen</a> for this contributions.
43-
</li>
44-
<li>
45-
Merged <a href="https://github.com/exceljs/exceljs/pull/926">added explicit return types to the type definitions of Worksheet.protect() and Worksheet.unprotect() #926</a>.
46-
Many thanks to <a href="https://github.com/drjokepu">Tamas Czinege</a> for this contributions.
47-
</li>
48-
<li>
49-
Dropped dependencies on Promise libraries.
50-
</li>
51-
</ul>
28+
Prior to this release, the transpiled ES5 code was exported as the package main.
29+
From now on, the package main comes directly from the lib/ folder
30+
31+
** ES5 and Browserify are Still Included **
32+
33+
In order to support those that still require ES5 ready code (e.g. as dependencies in web apps)
34+
the source code will still be transpiled and available in dist/es5.
35+
36+
The ES5 code is also browserified and available as dist/exceljs.js or dist/exceljs.min.js
37+
38+
* See the section <a href="#importing">Importing</a> for details *
5239

5340
# Contributions
5441

@@ -72,6 +59,7 @@ To be clear, all contributions added to this library will be included in the lib
7259
# Contents
7360

7461
<ul>
62+
<li><a href="#importing">Importing</a></li>
7563
<li>
7664
<a href="#interface">Interface</a>
7765
<ul>
@@ -164,6 +152,38 @@ To be clear, all contributions added to this library will be included in the lib
164152
<li><a href="#release-history">Release History</a></li>
165153
</ul>
166154

155+
# Importing
156+
157+
```javascript
158+
const ExcelJS = require('exceljs');
159+
```
160+
161+
## ES5 Imports
162+
163+
To use the ES5 transpiled code, use the dist/es5 path.
164+
165+
```javascript
166+
const ExcelJS = require('exceljs/dist/es5');
167+
```
168+
169+
**Note:** The ES5 build has an implicit dependency on a number of polyfills.
170+
You will need to include the following requires in your code before the exceljs import:
171+
172+
```javascript
173+
// polyfills required by exceljs
174+
require('core-js/modules/es.promise');
175+
require('core-js/modules/es.object.assign');
176+
require('core-js/modules/es.object.keys');
177+
require('regenerator-runtime/runtime');
178+
```
179+
180+
## Browserify
181+
182+
```html
183+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.js"></script>
184+
<script src="exceljs.js"></script>
185+
```
186+
167187
# Interface
168188

169189
## Importing
@@ -2323,4 +2343,4 @@ If any splice operation affects a merged cell, the merge group will not be moved
23232343
| 1.13.0 | <ul> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/862">zip: allow tuning compression for performance or size #862</a>. Many thanks to <a href="https://github.com/myfreeer">myfreeer</a> for this contribution. </li> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/863">Feat configure headers and footers #863</a>. Many thanks to <a href="https://github.com/autukill">autukill</a> for this contribution. </li> <li> Fixed an issue with defaultRowHeight where the default value resulted in 'customHeight' property being set. </li> </ul> |
23242344
| 1.14.0 | <ul> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/874">Fix header and footer text format error in README.md #874</a>. Many thanks to <a href="https://github.com/autukill">autukill</a> for this contribution. </li> <li> Added Tables. See <a href="#tables">Tables</a> for details. </li> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/887">fix: #877 and #880</a>. Many thanks to <a href="https://github.com/aexei">Alexander Heinrich</a> for this contribution. This fixes <a href="https://github.com/exceljs/exceljs/pull/877">bug: Hyperlink without text crashes write #877</a> and <a href="https://github.com/exceljs/exceljs/pull/880">bug: malformed comment crashes on write #880</a> </li> </ul> |
23252345
| 1.15.0 | <ul> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/889">Add Compression level option to WorkbookWriterOptions for streaming #889</a>. Many thanks to <a href="https://github.com/ABenassi87">Alfredo Benassi</a> for this contribution. </li> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/903">Feature/Cell Protection #903</a> and <a href="https://github.com/exceljs/exceljs/pull/907">Feature/Sheet Protection #907</a>. Many thanks to <a href="https://github.com/karabaesh">karabaesh</a> for these contributions. </li> </ul> |
2326-
2346+
| 2.0.1 | <h2>Major Version Change</h2> <p>Introducing async/await to ExcelJS!</p> <p>The new async and await features of JavaScript can help a lot to make code more readable and maintainable. To avoid confusion, particularly with returned promises from async functions, we have had to remove the Promise class configuration option and from v2 onwards ExcelJS will use native Promises. Since this is potentially a breaking change we're bumping the major version for this release.</p> <h2>Changes</h2> <ul> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/829">Introduce async/await #829</a>. Many thanks to <a href="https://github.com/alubbe">Andreas Lubbe</a> for this contribution. </li> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/930">Update index.d.ts #930</a>. Many thanks to <a href="https://github.com/cosmonovallc">cosmonovallc</a> for this contributions. </li> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/940">TS: Add types for addTable function #940</a>. Many thanks to <a href="https://github.com/egmen">egmen</a> for this contributions. </li> <li> Merged <a href="https://github.com/exceljs/exceljs/pull/926">added explicit return types to the type definitions of Worksheet.protect() and Worksheet.unprotect() #926</a>. Many thanks to <a href="https://github.com/drjokepu">Tamas Czinege</a> for this contributions. </li> <li> Dropped dependencies on Promise libraries. </li> </ul> |

lib/exceljs.nodejs.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
require('core-js/modules/es.promise');
2-
require('core-js/modules/es.object.assign');
3-
require('core-js/modules/es.object.keys');
4-
require('regenerator-runtime/runtime');
5-
61
const ExcelJS = {
72
Workbook: require('./doc/workbook'),
83
ModelContainer: require('./doc/modelcontainer'),

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"engines": {
1616
"node": ">=6.0.0"
1717
},
18-
"main": "./dist/es5/index.js",
19-
"browser": "./dist/es5/exceljs.browser.js",
18+
"main": "./lib/exceljs.nodejs.js",
19+
"browser": "./dist/exceljs.min.js",
2020
"types": "./index.d.ts",
2121
"files": [
2222
"dist",
@@ -31,11 +31,16 @@
3131
"pretest": "npm run build",
3232
"test": "npm run test:full",
3333
"test:full": "npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser",
34-
"test:unit": "mocha --require spec/config/setup spec/unit --require spec/config/setup-unit --recursive",
34+
"test:all": "npm run test:native && npm run test:es5",
35+
"test:native": "npm run test:full",
36+
"test:es5": "export EXCEL_BUILD=es5 && npm run test:full",
37+
"test:unit": "mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive",
3538
"test:integration": "mocha --require spec/config/setup spec/integration --recursive",
3639
"test:end-to-end": "mocha --require spec/config/setup spec/end-to-end --recursive",
37-
"test:browser": "if [ ! -f .disable-test-browser ]; then ./node_modules/.bin/grunt jasmine; fi ",
38-
"test:native-integration": "export EXCEL_NATIVE=yes && mocha --require spec/config/setup spec/integration --recursive",
40+
"test:browser": "if [ ! -f .disable-test-browser ]; then ./node_modules/.bin/grunt jasmine; fi",
41+
"test:unit:es5": "export EXCEL_BUILD=es5 && npm run test:unit",
42+
"test:integration:es5": "export EXCEL_BUILD=es5 && npm run test:integration",
43+
"test:end-to-end:es5": "export EXCEL_BUILD=es5 && npm run test:end-to-end",
3944
"test:manual": "node spec/manual/app.js",
4045
"clean-build": "npm run clean && npm run build",
4146
"lint": "eslint --format node_modules/eslint-friendly-formatter .",
@@ -84,11 +89,9 @@
8489
],
8590
"dependencies": {
8691
"archiver": "^3.0.0",
87-
"core-js": "^3.2.1",
8892
"fast-csv": "^2.4.1",
8993
"jszip": "^3.1.5",
9094
"dayjs": "^1.8.15",
91-
"regenerator-runtime": "^0.13.3",
9295
"sax": "^1.2.4",
9396
"tmp": "^0.1.0",
9497
"unzipper": "^0.9.12"
@@ -102,6 +105,7 @@
102105
"chai": "^4.2.0",
103106
"chai-datetime": "^1.5.0",
104107
"chai-xml": "^0.3.2",
108+
"core-js": "^3.2.1",
105109
"dirty-chai": "^2.0.1",
106110
"eslint": "^5.7.0",
107111
"eslint-config-airbnb": "^17.1.0",
@@ -125,6 +129,7 @@
125129
"mocha": "^5.2.0",
126130
"prettier-eslint": "^8.8.1",
127131
"prettier-eslint-cli": "^4.6.1",
132+
"regenerator-runtime": "^0.13.3",
128133
"request": "^2.88.0",
129134
"semver": "^5.6.0",
130135
"uglify-js": "^3.4.9"

spec/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"no-underscore-dangle": ["off"]
1111
},
1212
"globals": {
13+
"verquire": true,
1314
"describe": true,
1415
"expect": true,
1516
"before": true,

spec/config/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const chai = require('chai');
33
const chaiXml = require('chai-xml');
44
const chaiDatetime = require('chai-datetime');
55
const dirtyChai = require('dirty-chai');
6+
global.verquire = require('../utils/verquire');
67

78
chai.use(chaiXml);
89
chai.use(chaiDatetime);
910
chai.use(dirtyChai);
11+

spec/end-to-end/express.spec.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
'use strict';
2-
31
const express = require('express');
42
const request = require('request');
5-
const verquire = require('../utils/verquire');
63
const testutils = require('../utils/index');
74

8-
const Excel = verquire('excel');
5+
const Excel = verquire('exceljs');
96

107
// =============================================================================
118
// Tests

spec/integration/gold.spec.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
'use strict';
1+
const {expect} = require('chai');
22

3-
const chai = require('chai');
4-
const verquire = require('../utils/verquire');
5-
6-
const Excel = verquire('excel');
7-
8-
const { expect } = chai;
3+
const ExcelJS = verquire('exceljs');
94

105
// =============================================================================
116
// This spec is based around a gold standard Excel workbook 'gold.xlsx'
@@ -14,7 +9,7 @@ describe('Gold Book', () => {
149
describe('Read', () => {
1510
let wb;
1611
before(() => {
17-
wb = new Excel.Workbook();
12+
wb = new ExcelJS.Workbook();
1813
return wb.xlsx.readFile(`${__dirname}/data/gold.xlsx`);
1914
});
2015

@@ -40,6 +35,7 @@ describe('Gold Book', () => {
4035
});
4136
});
4237

43-
it('Styles', () => {});
38+
it('Styles', () => {
39+
});
4440
});
4541
});

spec/integration/issues/issue-163-xlsx-read-file.spec.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
'use strict';
1+
const {expect} = require('chai');
22

3-
const chai = require('chai');
4-
const verquire = require('../../utils/verquire');
5-
6-
const Excel = verquire('excel');
7-
8-
const { expect } = chai;
3+
const ExcelJS = verquire('exceljs');
94

105
describe('github issues', () => {
116
it('issue 163 - Error while using xslx readFile method', () => {
12-
const wb = new Excel.Workbook();
7+
const wb = new ExcelJS.Workbook();
138
return wb.xlsx
149
.readFile('./spec/integration/data/test-issue-163.xlsx')
1510
.then(() => {

spec/integration/issues/issue-176-unexpected-xml-node.spec.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
'use strict';
1+
const {expect} = require('chai');
22

3-
const chai = require('chai');
4-
5-
const verquire = require('../../utils/verquire');
6-
7-
const Excel = verquire('excel');
8-
9-
const { expect } = chai;
3+
const ExcelJS = verquire('exceljs');
104

115
describe('github issues', () => {
126
it('issue 176 - Unexpected xml node in parseOpen', () => {
13-
const wb = new Excel.Workbook();
7+
const wb = new ExcelJS.Workbook();
148
return wb.xlsx
159
.readFile('./spec/integration/data/test-issue-176.xlsx')
1610
.then(() => {

spec/integration/issues/issue-219-1904-dates.spec.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
'use strict';
1+
const {expect} = require('chai');
22

3-
const chai = require('chai');
4-
5-
const verquire = require('../../utils/verquire');
6-
7-
const Excel = verquire('excel');
8-
9-
const { expect } = chai;
3+
const ExcelJS = verquire('exceljs');
104

115
// this file to contain integration tests created from github issues
126
const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';
137

148
describe('github issues', () => {
159
describe('issue 219 - 1904 dates not supported', () => {
1610
it('Reading 1904.xlsx', () => {
17-
const wb = new Excel.Workbook();
11+
const wb = new ExcelJS.Workbook();
1812
return wb.xlsx.readFile('./spec/integration/data/1904.xlsx').then(() => {
1913
expect(wb.properties.date1904).to.equal(true);
2014

@@ -25,14 +19,14 @@ describe('github issues', () => {
2519
});
2620
});
2721
it('Writing and Reading', () => {
28-
const wb = new Excel.Workbook();
22+
const wb = new ExcelJS.Workbook();
2923
wb.properties.date1904 = true;
3024
const ws = wb.addWorksheet('Sheet1');
3125
ws.getCell('B4').value = new Date('1904-01-01T00:00:00.000Z');
3226
return wb.xlsx
3327
.writeFile(TEST_XLSX_FILE_NAME)
3428
.then(() => {
35-
const wb2 = new Excel.Workbook();
29+
const wb2 = new ExcelJS.Workbook();
3630
return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME);
3731
})
3832
.then(wb2 => {

spec/integration/issues/issue-234-vertical-tab-char.spec.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
'use strict';
1+
const {expect} = require('chai');
22

3-
const chai = require('chai');
4-
5-
const verquire = require('../../utils/verquire');
6-
7-
const Excel = verquire('excel');
8-
9-
const { expect } = chai;
3+
const ExcelJS = verquire('exceljs');
104

115
// this file to contain integration tests created from github issues
126
const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';
137

148
describe('github issues', () => {
159
it('issue 234 - Broken XLSX because of "vertical tab" ascii character in a cell', () => {
16-
const wb = new Excel.Workbook();
10+
const wb = new ExcelJS.Workbook();
1711
const ws = wb.addWorksheet('Sheet1');
1812

1913
// Start of Heading
@@ -25,7 +19,7 @@ describe('github issues', () => {
2519
return wb.xlsx
2620
.writeFile(TEST_XLSX_FILE_NAME)
2721
.then(() => {
28-
const wb2 = new Excel.Workbook();
22+
const wb2 = new ExcelJS.Workbook();
2923
return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME);
3024
})
3125
.then(wb2 => {

spec/integration/issues/issue-257-sheet-order.spec.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
'use strict';
1+
const {expect} = require('chai');
22

3-
const chai = require('chai');
4-
const verquire = require('../../utils/verquire');
5-
6-
const Excel = verquire('excel');
7-
8-
const { expect } = chai;
3+
const ExcelJS = verquire('exceljs');
94

105
describe('github issues', () => {
116
it('issue 257 - worksheet order is not respected', () => {
12-
const wb = new Excel.Workbook();
7+
const wb = new ExcelJS.Workbook();
138
return wb.xlsx
149
.readFile('./spec/integration/data/test-issue-257.xlsx')
1510
.then(() => {

0 commit comments

Comments
 (0)