excellentexport 3.8.0 → 3.9.0

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.
@@ -13,15 +13,18 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [14.x, 16.x]
16
+ node-version: [18.x]
17
17
 
18
18
  steps:
19
- - uses: actions/checkout@v2
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@v1
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 600+ KB.
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,17 @@
23
21
 
24
22
  # Revision history:
25
23
 
24
+ ### 3.9.0
25
+
26
+ * 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".
27
+
28
+ ### 3.8.1
29
+
30
+ * Activate XLSX compression by default. The example of index.bigtable.html went from 18Mb to 3Mb.
31
+ * _Update npm dependencies to fix vulnerabilities_
32
+ * Update to latest version of TypeScript
33
+ * Reduced size of the library from 912 KB to 277 KB!!!
34
+
26
35
  ### 3.8.0
27
36
 
28
37
  * Allow RTL options on the whole file or sheet.
@@ -153,7 +162,7 @@
153
162
  - Chrome
154
163
  - Internet Explorer 11+
155
164
 
156
- # Install
165
+ # Install
157
166
 
158
167
  ## npm
159
168
 
@@ -234,6 +243,7 @@
234
243
  fixValue: function(value, row, column) {return fixedValue} // Function to fix values, receiving value, row num, column num
235
244
  fixArray: function(array) {return array} // Function to manipulate the whole data array
236
245
  rtl: Use Right-to-left characters, boolean (optional)
246
+ formats: [...] // Array of formats for each column. See formats below.
237
247
  ...
238
248
  },
239
249
  {
@@ -243,7 +253,7 @@
243
253
 
244
254
  ## fixValue example
245
255
 
246
- This is an example for the _fixValue function_ to handle HTML tags inside a table cell.
256
+ This is an example for the _fixValue function_ to handle HTML tags inside a table cell.
247
257
  It transforms BR to line breaks and then strips all the HTML tags.
248
258
 
249
259
  fixValue: (value, row, col) => {
@@ -252,6 +262,47 @@ It transforms BR to line breaks and then strips all the HTML tags.
252
262
  return strippedString;
253
263
  }
254
264
 
265
+ ## Formats
266
+
267
+ You can specify an array with the formats for a specific cell range (i.e. A1:A100, A1:D100, A1:H1, etc).
268
+
269
+ Each element in the format array consists on:
270
+
271
+ ```json
272
+ {
273
+ "range": "A1:A100", // Range of cells to apply the format, mandatory
274
+ "format": {
275
+ "type": "<cell_type>", // Type of format, mandatory
276
+ "pattern": "<pattern>" // Pattern, optional
277
+ }
278
+ }
279
+ ```
280
+
281
+ `format` can be used from one of the predefined types if you use TypeScript
282
+
283
+ ```typescript
284
+ {
285
+ "range": "A1:A100",
286
+ "format": PredefinedFormat.INTEGER
287
+ }
288
+ ```
289
+
290
+ `cell_type` can be one of the followint:
291
+
292
+ 's': String
293
+ 'n': Number
294
+ 'd': Date
295
+ 'b': Boolean
296
+
297
+ `pattern` is a string with the format pattern used in Excel. For example:
298
+
299
+ '0' // Integer
300
+ '0.00' // 2 decimals
301
+ 'dd/mm/yyyy' // Date
302
+ 'dd/mm/yyyy hh:mm:ss' // Date and time
303
+ '0.00%' // Percentage
304
+ '0.00e+00' // Scientific notation
305
+ '@' // Text
255
306
 
256
307
  # Notes
257
308
 
@@ -272,7 +323,7 @@ It transforms BR to line breaks and then strips all the HTML tags.
272
323
  **Install dependencies:**
273
324
 
274
325
  npm install
275
-
326
+
276
327
  **Build development version dist/excellentexport.js**
277
328
 
278
329
  npm run build
@@ -6,6 +6,12 @@
6
6
  * @url: https://github.com/jmaister/excellentexport
7
7
  *
8
8
  */
9
+ import { FormatDefinition } from './format';
10
+ declare global {
11
+ interface Navigator {
12
+ msSaveBlob?: (blob: any, defaultName?: string) => boolean;
13
+ }
14
+ }
9
15
  export interface ConvertOptions {
10
16
  anchor?: (string | HTMLAnchorElement);
11
17
  openAsDownload?: boolean;
@@ -25,9 +31,11 @@ export interface SheetOptions {
25
31
  fixValue?(value: any, row: number, column: number): any;
26
32
  fixArray?(array: any[][]): any[][];
27
33
  rtl?: boolean;
34
+ formats?: (FormatDefinition | null)[];
28
35
  }
29
36
  declare const ExcellentExport: {
30
37
  version: () => string;
38
+ formats: import("./format").CellFormats;
31
39
  excel: (anchor: (HTMLAnchorElement | string), table: HTMLTableElement, name: string) => boolean;
32
40
  csv: (anchor: (HTMLAnchorElement | string), table: HTMLTableElement, delimiter?: string, newLine?: string) => boolean;
33
41
  convert: (options: ConvertOptions, sheets: SheetOptions[]) => string | false;