excellentexport 3.8.1 → 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.
@@ -16,12 +16,15 @@ jobs:
16
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,10 @@
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
+
26
28
  ### 3.8.1
27
29
 
28
30
  * Activate XLSX compression by default. The example of index.bigtable.html went from 18Mb to 3Mb.
@@ -160,7 +162,7 @@
160
162
  - Chrome
161
163
  - Internet Explorer 11+
162
164
 
163
- # Install
165
+ # Install
164
166
 
165
167
  ## npm
166
168
 
@@ -241,6 +243,7 @@
241
243
  fixValue: function(value, row, column) {return fixedValue} // Function to fix values, receiving value, row num, column num
242
244
  fixArray: function(array) {return array} // Function to manipulate the whole data array
243
245
  rtl: Use Right-to-left characters, boolean (optional)
246
+ formats: [...] // Array of formats for each column. See formats below.
244
247
  ...
245
248
  },
246
249
  {
@@ -250,7 +253,7 @@
250
253
 
251
254
  ## fixValue example
252
255
 
253
- 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.
254
257
  It transforms BR to line breaks and then strips all the HTML tags.
255
258
 
256
259
  fixValue: (value, row, col) => {
@@ -259,6 +262,47 @@ It transforms BR to line breaks and then strips all the HTML tags.
259
262
  return strippedString;
260
263
  }
261
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
262
306
 
263
307
  # Notes
264
308
 
@@ -279,7 +323,7 @@ It transforms BR to line breaks and then strips all the HTML tags.
279
323
  **Install dependencies:**
280
324
 
281
325
  npm install
282
-
326
+
283
327
  **Build development version dist/excellentexport.js**
284
328
 
285
329
  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;