excellentexport 3.8.1 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/webpack.yml +5 -2
- package/README.md +54 -6
- package/dist/excellentexport.d.ts +3 -0
- package/dist/excellentexport.js +1 -1
- package/dist/format.d.ts +30 -0
- package/dist/index.d.ts +3 -0
- package/dist/utils.d.ts +1 -0
- package/index.format.html +100 -0
- package/package.json +1 -1
- package/src/excellentexport.ts +35 -3
- package/src/format.ts +56 -0
- package/src/index.ts +4 -0
- package/src/utils.ts +145 -141
- package/test/convert.format.ts +56 -0
|
@@ -16,12 +16,15 @@ jobs:
|
|
|
16
16
|
node-version: [18.x]
|
|
17
17
|
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
20
22
|
|
|
21
23
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
22
|
-
uses: actions/setup-node@
|
|
24
|
+
uses: actions/setup-node@v3
|
|
23
25
|
with:
|
|
24
26
|
node-version: ${{ matrix.node-version }}
|
|
27
|
+
cache: 'yarn'
|
|
25
28
|
|
|
26
29
|
- run: yarn install
|
|
27
30
|
|
package/README.md
CHANGED
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
- A quick JavaScript library to create export to Excel/CSV from HTML tables in the browser. No server required.
|
|
14
14
|
|
|
15
|
-
- As part of the new version 3.0.0+, there is support for _XLSX_. The drawback is that the library is
|
|
16
|
-
|
|
17
|
-
- If you only need _XLS_ or _CSV_, use _2.X.X_ versions.
|
|
15
|
+
- As part of the new version 3.0.0+, there is support for _XLSX_. The drawback is that the library is 200+ KB.
|
|
18
16
|
|
|
19
17
|
- Check My Blog Page for Testing :
|
|
20
18
|
[JavaScript export to Excel](http://jordiburgos.com/post/2013/javascript-export-to-excel.html)
|
|
@@ -23,6 +21,14 @@
|
|
|
23
21
|
|
|
24
22
|
# Revision history:
|
|
25
23
|
|
|
24
|
+
### 3.9.1
|
|
25
|
+
|
|
26
|
+
* Fix TypeScript exported types
|
|
27
|
+
|
|
28
|
+
### 3.9.0
|
|
29
|
+
|
|
30
|
+
* Cell types and formats!!! Now you can define the cell type and format. For example, you can define a cell as a date or a number. You can also define the format of the cell. For example, you can define a cell as a date with the format "dd/mm/yyyy" or a number with the format "#,##0.00".
|
|
31
|
+
|
|
26
32
|
### 3.8.1
|
|
27
33
|
|
|
28
34
|
* Activate XLSX compression by default. The example of index.bigtable.html went from 18Mb to 3Mb.
|
|
@@ -160,7 +166,7 @@
|
|
|
160
166
|
- Chrome
|
|
161
167
|
- Internet Explorer 11+
|
|
162
168
|
|
|
163
|
-
# Install
|
|
169
|
+
# Install
|
|
164
170
|
|
|
165
171
|
## npm
|
|
166
172
|
|
|
@@ -241,6 +247,7 @@
|
|
|
241
247
|
fixValue: function(value, row, column) {return fixedValue} // Function to fix values, receiving value, row num, column num
|
|
242
248
|
fixArray: function(array) {return array} // Function to manipulate the whole data array
|
|
243
249
|
rtl: Use Right-to-left characters, boolean (optional)
|
|
250
|
+
formats: [...] // Array of formats for each column. See formats below.
|
|
244
251
|
...
|
|
245
252
|
},
|
|
246
253
|
{
|
|
@@ -250,7 +257,7 @@
|
|
|
250
257
|
|
|
251
258
|
## fixValue example
|
|
252
259
|
|
|
253
|
-
This is an example for the _fixValue function_ to handle HTML tags inside a table cell.
|
|
260
|
+
This is an example for the _fixValue function_ to handle HTML tags inside a table cell.
|
|
254
261
|
It transforms BR to line breaks and then strips all the HTML tags.
|
|
255
262
|
|
|
256
263
|
fixValue: (value, row, col) => {
|
|
@@ -259,6 +266,47 @@ It transforms BR to line breaks and then strips all the HTML tags.
|
|
|
259
266
|
return strippedString;
|
|
260
267
|
}
|
|
261
268
|
|
|
269
|
+
## Formats
|
|
270
|
+
|
|
271
|
+
You can specify an array with the formats for a specific cell range (i.e. A1:A100, A1:D100, A1:H1, etc).
|
|
272
|
+
|
|
273
|
+
Each element in the format array consists on:
|
|
274
|
+
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
277
|
+
"range": "A1:A100", // Range of cells to apply the format, mandatory
|
|
278
|
+
"format": {
|
|
279
|
+
"type": "<cell_type>", // Type of format, mandatory
|
|
280
|
+
"pattern": "<pattern>" // Pattern, optional
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`format` can be used from one of the predefined types if you use TypeScript
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
{
|
|
289
|
+
"range": "A1:A100",
|
|
290
|
+
"format": PredefinedFormat.INTEGER
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
`cell_type` can be one of the followint:
|
|
295
|
+
|
|
296
|
+
's': String
|
|
297
|
+
'n': Number
|
|
298
|
+
'd': Date
|
|
299
|
+
'b': Boolean
|
|
300
|
+
|
|
301
|
+
`pattern` is a string with the format pattern used in Excel. For example:
|
|
302
|
+
|
|
303
|
+
'0' // Integer
|
|
304
|
+
'0.00' // 2 decimals
|
|
305
|
+
'dd/mm/yyyy' // Date
|
|
306
|
+
'dd/mm/yyyy hh:mm:ss' // Date and time
|
|
307
|
+
'0.00%' // Percentage
|
|
308
|
+
'0.00e+00' // Scientific notation
|
|
309
|
+
'@' // Text
|
|
262
310
|
|
|
263
311
|
# Notes
|
|
264
312
|
|
|
@@ -279,7 +327,7 @@ It transforms BR to line breaks and then strips all the HTML tags.
|
|
|
279
327
|
**Install dependencies:**
|
|
280
328
|
|
|
281
329
|
npm install
|
|
282
|
-
|
|
330
|
+
|
|
283
331
|
**Build development version dist/excellentexport.js**
|
|
284
332
|
|
|
285
333
|
npm run build
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @url: https://github.com/jmaister/excellentexport
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
+
import { FormatDefinition } from './format';
|
|
9
10
|
declare global {
|
|
10
11
|
interface Navigator {
|
|
11
12
|
msSaveBlob?: (blob: any, defaultName?: string) => boolean;
|
|
@@ -30,9 +31,11 @@ export interface SheetOptions {
|
|
|
30
31
|
fixValue?(value: any, row: number, column: number): any;
|
|
31
32
|
fixArray?(array: any[][]): any[][];
|
|
32
33
|
rtl?: boolean;
|
|
34
|
+
formats?: (FormatDefinition | null)[];
|
|
33
35
|
}
|
|
34
36
|
declare const ExcellentExport: {
|
|
35
37
|
version: () => string;
|
|
38
|
+
formats: import("./format").CellFormats;
|
|
36
39
|
excel: (anchor: (HTMLAnchorElement | string), table: HTMLTableElement, name: string) => boolean;
|
|
37
40
|
csv: (anchor: (HTMLAnchorElement | string), table: HTMLTableElement, delimiter?: string, newLine?: string) => boolean;
|
|
38
41
|
convert: (options: ConvertOptions, sheets: SheetOptions[]) => string | false;
|