Skip to content

Commit

Permalink
Merge branch 'master' into fix/unhandledRejectionOnParseError
Browse files Browse the repository at this point in the history
  • Loading branch information
guyonroche authored May 16, 2019
2 parents 7dffb2b + 9bf2eac commit 2327a09
Show file tree
Hide file tree
Showing 35 changed files with 908 additions and 674 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"quotes": ["error", "single"],
"semi": ["error", "always"],
"space-before-function-paren": ["error", "never"],
"strict": ["off"]
"strict": ["off"],
"class-methods-use-this": ["off"]
}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ spec/integration/data/gold
/spec/manual/public/exceljs.js
/spec/manual/public/exceljs.min.js

package-lock.json
package-lock.json

# optional switch off tests
.disable-test-*
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ npm install exceljs
Merged <a href="https://github.com/exceljs/exceljs/pull/799">Add support for repeated columns on every page when printing. #799</a>.
Many thanks to <a href="https://github.com/FreakenK">Jasmin Auger</a> for this contribution.
</li>
<li>
Merged <a href="https://github.com/exceljs/exceljs/pull/815">Do not use a promise polyfill on modern setups #815</a>.
Many thanks to <a href="https://github.com/alubbe">Andreas Lubbe</a> for this contribution.
</li>
</ul>

# Contributions
Expand Down Expand Up @@ -139,11 +143,20 @@ To be clear, all contributions added to this library will be included in the lib

# Interface

## Importing

The default export is a transpiled ES5 version with a Promise polyfill - this offers the highest level of compatibility.

```javascript
var Excel = require('exceljs');
import Excel from 'exceljs';
```

// or, for node.js version 8+
const Excel = require('exceljs/nodejs');
However, if you use this library on a modern node.js version (>=8) or on the frontend using a bundler (or can focus on just evergreen browsers), we recommend to use these imports:

```javascript
const Excel = require('exceljs/modern.nodejs');
import Excel from 'exceljs/modern.browser';
```

## Create a Workbook
Expand Down Expand Up @@ -896,6 +909,7 @@ font.size = 20; // Cell A3 now has font size 20!
| family | Font family for fallback. An integer value. | 1 - Serif, 2 - Sans Serif, 3 - Mono, Others - unknown |
| scheme | Font scheme. | 'minor', 'major', 'none' |
| charset | Font charset. An integer value. | 1, 2, etc. |
| size | Font size. An integer value. | 9, 10, 12, 16, etc. |
| color | Colour description, an object containing an ARGB value. | { argb: 'FFFF0000'} |
| bold | Font **weight** | true, false |
| italic | Font *slope* | true, false |
Expand Down Expand Up @@ -1033,7 +1047,6 @@ ws.getCell('A2').fill = {

* none
* solid
* darkVertical
* darkGray
* mediumGray
* lightGray
Expand All @@ -1051,7 +1064,6 @@ ws.getCell('A2').fill = {
* lightUp
* lightGrid
* lightTrellis
* lightGrid

#### Gradient Fills

Expand All @@ -1070,7 +1082,7 @@ For example, Excel only supports angle gradients of 0, 45, 90 and 135.
Similarly the sequence of stops may also be limited by the UI with positions [0,1] or [0,0.5,1] as the only options.
Take care with this fill to be sure it is supported by the target XLSX viewers.

#### Rich Text
### Rich Text

Individual cells now support rich text or in-cell formatting.
Rich text values can control the font properties of any number of sub-strings within the text value.
Expand Down
6 changes: 3 additions & 3 deletions lib/config/set-value.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const PromishLib = require('../utils/promish');
const PromiseLib = require('../utils/promise');

function setValue(key, value, overwrite) {
if (overwrite === undefined) {
Expand All @@ -9,8 +9,8 @@ function setValue(key, value, overwrite) {
}
switch (key.toLowerCase()) {
case 'promise':
if (!overwrite && PromishLib.Promish) return;
PromishLib.Promish = value;
if (!overwrite && PromiseLib.Promise) return;
PromiseLib.Promise = value;
break;
default:
break;
Expand Down
18 changes: 9 additions & 9 deletions lib/csv/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs');
const csv = require('fast-csv');
const moment = require('moment');
const PromishLib = require('../utils/promish');
const PromiseLib = require('../utils/promise');
const StreamBuf = require('../utils/stream-buf');

const utils = require('../utils/utils');
Expand Down Expand Up @@ -48,7 +48,7 @@ CSV.prototype = {
},
read(stream, options) {
options = options || {};
return new PromishLib.Promish((resolve, reject) => {
return new PromiseLib.Promise((resolve, reject) => {
const csvStream = this.createInputStream(options)
.on('worksheet', resolve)
.on('error', reject);
Expand All @@ -67,8 +67,9 @@ CSV.prototype = {
if (datum === '') {
return null;
}
if (!isNaN(datum)) {
return parseFloat(datum);
const datumNumber = Number(datum);
if (!Number.isNaN(datumNumber)) {
return datumNumber;
}
const dt = moment(datum, dateFormats, true);
if (dt.isValid()) {
Expand All @@ -92,7 +93,7 @@ CSV.prototype = {
},

write(stream, options) {
return new PromishLib.Promish((resolve, reject) => {
return new PromiseLib.Promise((resolve, reject) => {
options = options || {};
// const encoding = options.encoding || 'utf8';
// const separator = options.separator || ',';
Expand All @@ -107,8 +108,7 @@ CSV.prototype = {
csvStream.on('error', reject);
csvStream.pipe(stream);

const dateFormat = options.dateFormat;
const dateUTC = options.dateUTC;
const {dateFormat, dateUTC} = options;
const map =
options.map ||
(value => {
Expand All @@ -121,7 +121,7 @@ CSV.prototype = {
}
if (value instanceof Date) {
if (dateFormat) {
dateUTC ? moment.utc(value).format(dateFormat) : moment(value).format(dateFormat);
return dateUTC ? moment.utc(value).format(dateFormat) : moment(value).format(dateFormat);
}
return dateUTC ? moment.utc(value).format() : moment(value).format();
}
Expand All @@ -144,7 +144,7 @@ CSV.prototype = {
csvStream.write([]);
}
}
const values = row.values;
const {values} = row;
values.shift();
csvStream.write(values.map(map));
lastRow = rowNumber;
Expand Down
Loading

0 comments on commit 2327a09

Please sign in to comment.