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.
@@ -0,0 +1,29 @@
1
+ export declare enum CellType {
2
+ TEXT = "s",
3
+ NUMBER = "n",
4
+ DATE = "d",
5
+ BOOLEAN = "b"
6
+ }
7
+ export declare enum CellPattern {
8
+ INTEGER = "0",
9
+ DECIMAL = "0.00",
10
+ DATE = "dd/mm/yyyy",
11
+ TIME = "hh:mm:ss",
12
+ DATETIME = "dd/mm/yyyy hh:mm:ss",
13
+ CURRENCY = "[$$-409]#,##0.00;[RED]-[$$-409]#,##0.00",
14
+ PERCENTAGE = "0.00%",
15
+ EXPONENT = "0.00E+00",
16
+ TEXT = "@"
17
+ }
18
+ export interface CellFormat {
19
+ type: CellType;
20
+ pattern?: CellPattern;
21
+ }
22
+ export interface CellFormats {
23
+ [key: string]: CellFormat;
24
+ }
25
+ export declare const PredefinedFormat: CellFormats;
26
+ export interface FormatDefinition {
27
+ range: string;
28
+ format?: CellFormat;
29
+ }
package/dist/utils.d.ts CHANGED
@@ -27,3 +27,4 @@ export declare const tableToCSV: (table: HTMLTableElement, csvDelimiter?: string
27
27
  export declare const createDownloadLink: (anchor: HTMLAnchorElement, base64data: string, exporttype: string, filename: string) => boolean;
28
28
  export declare const string2ArrayBuffer: (s: string) => ArrayBuffer;
29
29
  export declare const removeColumns: (dataArray: any[][], columnIndexes: number[]) => void;
30
+ export declare const hasContent: (value: any) => boolean;
@@ -0,0 +1,100 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Export to excel test</title>
6
+ <script src="dist/excellentexport.js"></script>
7
+ <style>
8
+ table, tr, td {
9
+ border: 1px black solid;
10
+ }
11
+ </style>
12
+ <script>
13
+ function newApi(format) {
14
+ return ExcellentExport.convert({
15
+ anchor: 'anchorNewApi-' + format,
16
+ filename: 'data',
17
+ format: format
18
+ }, [{
19
+ name: 'Formatted Sheet',
20
+ from: {
21
+ table: 'datatable'
22
+ },
23
+ formats: [
24
+ { range: "A2:A10", format: ExcellentExport.formats.INTEGER },
25
+ { range: "B2:B10", format: ExcellentExport.formats.TEXT },
26
+ { range: "C2:C10", format: ExcellentExport.formats.DATE },
27
+ { range: "D2:D10", format: ExcellentExport.formats.DECIMAL },
28
+ { range: "E2:E10", format: ExcellentExport.formats.BOOLEAN },
29
+ { range: "F2:F10", format: ExcellentExport.formats.INTEGER },
30
+ { range: "A5:E5", format: ExcellentExport.formats.TEXT },
31
+ { range: "A6", format: ExcellentExport.formats.DECIMAL },
32
+ ],
33
+ }]);
34
+ }
35
+ </script>
36
+ </head>
37
+ <body>
38
+ <h1>ExcellentExport.js</h1>
39
+
40
+ <h3>Test page</h3>
41
+
42
+ Test table:
43
+ <table id="datatable">
44
+ <tr>
45
+ <th>ID</th>
46
+ <th>Name</th>
47
+ <th>Birthdate</th>
48
+ <th>Salary</th>
49
+ <th>Active</th>
50
+ <th>Big number</th>
51
+ </tr>
52
+ <tr>
53
+ <td>1</td>
54
+ <td>John</td>
55
+ <td>1980-12-10</td>
56
+ <td>98762000.55</td>
57
+ <td>1</td>
58
+ <td>987654321987654</td>
59
+ </tr>
60
+ <tr>
61
+ <td>2</td>
62
+ <td>Peter</td>
63
+ <td>1978-01-23</td>
64
+ <td>98762500.43</td>
65
+ <td>0</td>
66
+ <td>876543219987654</td>
67
+ </tr>
68
+ <tr>
69
+ <td>3</td>
70
+ <td>George</td>
71
+ <td>1985-11-30</td>
72
+ <td>98761800.98</td>
73
+ <td>1</td>
74
+ <td>765432198987654</td>
75
+ </tr>
76
+ <tr>
77
+ <td>End</td>
78
+ <td>End</td>
79
+ <td>End</td>
80
+ <td>End</td>
81
+ <td>End</td>
82
+ <td>End</td>
83
+ </tr>
84
+ <tr>
85
+ <td>9876543.21</td>
86
+ <td></td>
87
+ <td></td>
88
+ <td></td>
89
+ <td></td>
90
+ <td></td>
91
+ </tr>
92
+ </table>
93
+
94
+ <br/>
95
+
96
+ <a href="#" id="anchorNewApi-xlsx" onclick="return newApi('xlsx');">Export Excel</a>
97
+ <a href="#" id="anchorNewApi-csv" onclick="return newApi('csv');">Export CSV</a>
98
+
99
+ </body>
100
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "excellentexport",
3
- "version": "3.8.1",
3
+ "version": "3.9.0",
4
4
  "description": "Client side JavaScript export to Excel or CSV",
5
5
  "license": "MIT",
6
6
  "homepage": "http://jordiburgos.com",
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import * as XLSX from 'xlsx';
11
+ import { CellType, FormatDefinition, PredefinedFormat } from './format';
11
12
 
12
13
  import * as utils from './utils';
13
14
 
@@ -29,6 +30,7 @@ export interface FromOptions {
29
30
  table?: (string|HTMLTableElement),
30
31
  array?: any[][],
31
32
  }
33
+
32
34
  export interface SheetOptions {
33
35
  name: string,
34
36
  from: FromOptions,
@@ -36,13 +38,13 @@ export interface SheetOptions {
36
38
  filterRowFn?(row:any[]): boolean ,
37
39
  fixValue?(value:any, row:number, column:number): any,
38
40
  fixArray?(array:any[][]): any[][],
39
- rtl?: boolean
41
+ rtl?: boolean,
42
+ formats?: (FormatDefinition | null)[],
40
43
  }
41
44
 
42
-
43
45
  const ExcellentExport = function() {
44
46
 
45
- const version = "3.8.1";
47
+ const version = "3.9.0";
46
48
 
47
49
  /*
48
50
  ExcellentExport.convert(options, sheets);
@@ -138,6 +140,35 @@ const ExcellentExport = function() {
138
140
  // Create sheet
139
141
  workbook.SheetNames.push(name);
140
142
  const worksheet = XLSX.utils.aoa_to_sheet(dataArray, {sheet: name} as XLSX.AOA2SheetOpts);
143
+
144
+ // Apply format
145
+ if (sheetConf.formats) {
146
+ sheetConf.formats.forEach(f => {
147
+ const range = XLSX.utils.decode_range(f.range);
148
+ for (let R = range.s.r; R <= range.e.r; ++R) {
149
+ for (let C = range.s.c; C <= range.e.c; ++C) {
150
+ const cell = worksheet[XLSX.utils.encode_cell({r: R, c: C})];
151
+ if (cell && utils.hasContent(cell.v)) {
152
+ // type
153
+ cell.t = f.format.type;
154
+
155
+ // type fix
156
+ if (f.format?.type == CellType.BOOLEAN) {
157
+ const v = cell.v.toString().toLowerCase();
158
+ if (v == 'true' || v == '1') cell.v = true;
159
+ if (v == 'false' || v == '0') cell.v = false;
160
+ }
161
+ // pattern
162
+ if (f.format?.pattern) {
163
+ cell.z = f.format.pattern;
164
+ }
165
+ }
166
+ }
167
+ }
168
+ });
169
+ }
170
+
171
+
141
172
  workbook.Sheets[name] = worksheet;
142
173
  workbook.Views.push({RTL: options.rtl || sheetConf.rtl || false});
143
174
  });
@@ -177,6 +208,7 @@ const ExcellentExport = function() {
177
208
  version: function(): string {
178
209
  return version;
179
210
  },
211
+ formats: PredefinedFormat,
180
212
  excel: function(anchor:(HTMLAnchorElement|string), table:HTMLTableElement, name:string) {
181
213
  table = utils.getTable(table);
182
214
  anchor = utils.getAnchor(anchor);
package/src/format.ts ADDED
@@ -0,0 +1,52 @@
1
+
2
+ export enum CellType {
3
+ TEXT = 's',
4
+ NUMBER = 'n',
5
+ DATE = 'd',
6
+ BOOLEAN = 'b',
7
+ }
8
+
9
+ export enum CellPattern {
10
+ INTEGER = '0',
11
+ DECIMAL = '0.00',
12
+ DATE = 'dd/mm/yyyy',
13
+ TIME = 'hh:mm:ss',
14
+ DATETIME = 'dd/mm/yyyy hh:mm:ss',
15
+ CURRENCY = '[$$-409]#,##0.00;[RED]-[$$-409]#,##0.00',
16
+ PERCENTAGE = '0.00%',
17
+ EXPONENT = '0.00E+00',
18
+ TEXT = '@',
19
+ }
20
+
21
+ export interface CellFormat {
22
+ type: CellType,
23
+ pattern?: CellPattern,
24
+ }
25
+
26
+ // Define structure for predefined formats
27
+ export interface CellFormats {
28
+ [key: string]: CellFormat
29
+ }
30
+ export const PredefinedFormat : CellFormats = {
31
+ NUMBER: { type: CellType.NUMBER},
32
+ INTEGER: { type: CellType.NUMBER, pattern: CellPattern.INTEGER },
33
+ DECIMAL: { type: CellType.NUMBER, pattern: CellPattern.DECIMAL },
34
+ CURRENCY: { type: CellType.NUMBER, pattern: CellPattern.CURRENCY },
35
+ PERCENTAGE: { type: CellType.NUMBER, pattern: CellPattern.PERCENTAGE },
36
+ EXPONENT: { type: CellType.NUMBER, pattern: CellPattern.EXPONENT },
37
+
38
+ DATE: { type: CellType.DATE, pattern: CellPattern.DATE },
39
+
40
+ TIME: { type: CellType.DATE, pattern: CellPattern.TIME },
41
+ DATETIME: { type: CellType.DATE, pattern: CellPattern.DATETIME },
42
+
43
+ TEXT: { type: CellType.TEXT, pattern: CellPattern.TEXT },
44
+
45
+ BOOLEAN: { type: CellType.BOOLEAN },
46
+ }
47
+
48
+ export interface FormatDefinition {
49
+ range: string,
50
+ format?: CellFormat,
51
+ }
52
+
package/src/utils.ts CHANGED
@@ -1,141 +1,145 @@
1
-
2
- export const b64toBlob = function (b64Data:string, contentType:string, sliceSize?:number): Blob {
3
- // function taken from http://stackoverflow.com/a/16245768/2591950
4
- // author Jeremy Banks http://stackoverflow.com/users/1114/jeremy-banks
5
- contentType = contentType || '';
6
- sliceSize = sliceSize || 512;
7
-
8
- const byteCharacters = atob(b64Data);
9
- const byteArrays = [];
10
-
11
- for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
12
- const slice = byteCharacters.slice(offset, offset + sliceSize);
13
-
14
- const byteNumbers = new Array(slice.length);
15
- for (let i = 0; i < slice.length; i = i + 1) {
16
- byteNumbers[i] = slice.charCodeAt(i);
17
- }
18
-
19
- const byteArray = new Uint8Array(byteNumbers);
20
-
21
- byteArrays.push(byteArray);
22
- }
23
-
24
- return new Blob(byteArrays, {
25
- type: contentType
26
- });
27
- };
28
-
29
- export const templates = {excel: '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'};
30
-
31
- /**
32
- * Convert a string to Base64.
33
- */
34
- export const base64 = function(s:string) : string {
35
- return btoa(unescape(encodeURIComponent(s)));
36
- };
37
-
38
- export const format = function(s:string, context:any) : string {
39
- return s.replace(new RegExp("{(\\w+)}", "g"), function(m, p) {
40
- return context[p] || "{" + p + "}";
41
- });
42
- };
43
-
44
- /**
45
- * Get element by ID.
46
- * @param {*} element
47
- */
48
- export const getTable = function(element :(HTMLTableElement|string)) : HTMLTableElement {
49
- if (typeof element === 'string') {
50
- return document.getElementById(element) as HTMLTableElement;
51
- }
52
- return element;
53
- };
54
-
55
- /**
56
- * Get element by ID.
57
- * @param {*} element
58
- */
59
- export const getAnchor = function(element :(HTMLAnchorElement|string)) : HTMLAnchorElement {
60
- if (typeof element === 'string') {
61
- return document.getElementById(element) as HTMLAnchorElement;
62
- }
63
- return element;
64
- };
65
-
66
- /**
67
- * Encode a value for CSV.
68
- * @param {*} value
69
- */
70
- export const fixCSVField = function(value:string, csvDelimiter:string) : string {
71
- let fixedValue = value;
72
- const addQuotes = (value.indexOf(csvDelimiter) !== -1) || (value.indexOf('\r') !== -1) || (value.indexOf('\n') !== -1);
73
- const replaceDoubleQuotes = (value.indexOf('"') !== -1);
74
-
75
- if (replaceDoubleQuotes) {
76
- fixedValue = fixedValue.replace(/"/g, '""');
77
- }
78
- if (addQuotes || replaceDoubleQuotes) {
79
- fixedValue = '"' + fixedValue + '"';
80
- }
81
-
82
- return fixedValue;
83
- };
84
-
85
- export const tableToArray = function(table:HTMLTableElement) : any[][] {
86
- let tableInfo = Array.prototype.map.call(table.querySelectorAll('tr'), function(tr) {
87
- return Array.prototype.map.call(tr.querySelectorAll('th,td'), function(td) {
88
- return td.innerHTML;
89
- });
90
- });
91
- return tableInfo;
92
- };
93
-
94
- export const tableToCSV = function(table:HTMLTableElement, csvDelimiter:string = ',', csvNewLine:string = '\n') : string {
95
- let data = "";
96
- for (let i = 0; i < table.rows.length; i=i+1) {
97
- const row = table.rows[i];
98
- for (let j = 0; j < row.cells.length; j=j+1) {
99
- const col = row.cells[j];
100
- data = data + (j ? csvDelimiter : '') + fixCSVField(col.textContent.trim(), csvDelimiter);
101
- }
102
- data = data + csvNewLine;
103
- }
104
- return data;
105
- };
106
-
107
- export const createDownloadLink = function(anchor:HTMLAnchorElement, base64data:string, exporttype:string, filename:string) : boolean {
108
- if (window.navigator.msSaveBlob) {
109
- const blob = b64toBlob(base64data, exporttype);
110
- window.navigator.msSaveBlob(blob, filename);
111
- return false;
112
- } else if (window.URL.createObjectURL) {
113
- const blob = b64toBlob(base64data, exporttype);
114
- anchor.href = window.URL.createObjectURL(blob);
115
- } else {
116
- anchor.download = filename;
117
- anchor.href = "data:" + exporttype + ";base64," + base64data;
118
- }
119
-
120
- // Return true to allow the link to work
121
- return true;
122
- };
123
-
124
- // String to ArrayBuffer
125
- export const string2ArrayBuffer = function (s:string): ArrayBuffer {
126
- let buf = new ArrayBuffer(s.length);
127
- let view = new Uint8Array(buf);
128
- for (let i=0; i !== s.length; ++i) {
129
- view[i] = s.charCodeAt(i) & 0xFF;
130
- }
131
- return buf;
132
- };
133
-
134
- export const removeColumns = function(dataArray:any[][], columnIndexes:number[]) {
135
- const uniqueIndexes = [...new Set(columnIndexes)].sort().reverse();
136
- uniqueIndexes.forEach(function(columnIndex) {
137
- dataArray.forEach(function(row) {
138
- row.splice(columnIndex, 1);
139
- });
140
- });
141
- };
1
+
2
+ export const b64toBlob = function (b64Data:string, contentType:string, sliceSize?:number): Blob {
3
+ // function taken from http://stackoverflow.com/a/16245768/2591950
4
+ // author Jeremy Banks http://stackoverflow.com/users/1114/jeremy-banks
5
+ contentType = contentType || '';
6
+ sliceSize = sliceSize || 512;
7
+
8
+ const byteCharacters = atob(b64Data);
9
+ const byteArrays = [];
10
+
11
+ for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
12
+ const slice = byteCharacters.slice(offset, offset + sliceSize);
13
+
14
+ const byteNumbers = new Array(slice.length);
15
+ for (let i = 0; i < slice.length; i = i + 1) {
16
+ byteNumbers[i] = slice.charCodeAt(i);
17
+ }
18
+
19
+ const byteArray = new Uint8Array(byteNumbers);
20
+
21
+ byteArrays.push(byteArray);
22
+ }
23
+
24
+ return new Blob(byteArrays, {
25
+ type: contentType
26
+ });
27
+ };
28
+
29
+ export const templates = {excel: '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'};
30
+
31
+ /**
32
+ * Convert a string to Base64.
33
+ */
34
+ export const base64 = function(s:string) : string {
35
+ return btoa(unescape(encodeURIComponent(s)));
36
+ };
37
+
38
+ export const format = function(s:string, context:any) : string {
39
+ return s.replace(new RegExp("{(\\w+)}", "g"), function(m, p) {
40
+ return context[p] || "{" + p + "}";
41
+ });
42
+ };
43
+
44
+ /**
45
+ * Get element by ID.
46
+ * @param {*} element
47
+ */
48
+ export const getTable = function(element :(HTMLTableElement|string)) : HTMLTableElement {
49
+ if (typeof element === 'string') {
50
+ return document.getElementById(element) as HTMLTableElement;
51
+ }
52
+ return element;
53
+ };
54
+
55
+ /**
56
+ * Get element by ID.
57
+ * @param {*} element
58
+ */
59
+ export const getAnchor = function(element :(HTMLAnchorElement|string)) : HTMLAnchorElement {
60
+ if (typeof element === 'string') {
61
+ return document.getElementById(element) as HTMLAnchorElement;
62
+ }
63
+ return element;
64
+ };
65
+
66
+ /**
67
+ * Encode a value for CSV.
68
+ * @param {*} value
69
+ */
70
+ export const fixCSVField = function(value:string, csvDelimiter:string) : string {
71
+ let fixedValue = value;
72
+ const addQuotes = (value.indexOf(csvDelimiter) !== -1) || (value.indexOf('\r') !== -1) || (value.indexOf('\n') !== -1);
73
+ const replaceDoubleQuotes = (value.indexOf('"') !== -1);
74
+
75
+ if (replaceDoubleQuotes) {
76
+ fixedValue = fixedValue.replace(/"/g, '""');
77
+ }
78
+ if (addQuotes || replaceDoubleQuotes) {
79
+ fixedValue = '"' + fixedValue + '"';
80
+ }
81
+
82
+ return fixedValue;
83
+ };
84
+
85
+ export const tableToArray = function(table:HTMLTableElement) : any[][] {
86
+ let tableInfo = Array.prototype.map.call(table.querySelectorAll('tr'), function(tr) {
87
+ return Array.prototype.map.call(tr.querySelectorAll('th,td'), function(td) {
88
+ return td.innerHTML;
89
+ });
90
+ });
91
+ return tableInfo;
92
+ };
93
+
94
+ export const tableToCSV = function(table:HTMLTableElement, csvDelimiter:string = ',', csvNewLine:string = '\n') : string {
95
+ let data = "";
96
+ for (let i = 0; i < table.rows.length; i=i+1) {
97
+ const row = table.rows[i];
98
+ for (let j = 0; j < row.cells.length; j=j+1) {
99
+ const col = row.cells[j];
100
+ data = data + (j ? csvDelimiter : '') + fixCSVField(col.textContent.trim(), csvDelimiter);
101
+ }
102
+ data = data + csvNewLine;
103
+ }
104
+ return data;
105
+ };
106
+
107
+ export const createDownloadLink = function(anchor:HTMLAnchorElement, base64data:string, exporttype:string, filename:string) : boolean {
108
+ if (window.navigator.msSaveBlob) {
109
+ const blob = b64toBlob(base64data, exporttype);
110
+ window.navigator.msSaveBlob(blob, filename);
111
+ return false;
112
+ } else if (window.URL.createObjectURL) {
113
+ const blob = b64toBlob(base64data, exporttype);
114
+ anchor.href = window.URL.createObjectURL(blob);
115
+ } else {
116
+ anchor.download = filename;
117
+ anchor.href = "data:" + exporttype + ";base64," + base64data;
118
+ }
119
+
120
+ // Return true to allow the link to work
121
+ return true;
122
+ };
123
+
124
+ // String to ArrayBuffer
125
+ export const string2ArrayBuffer = function (s:string): ArrayBuffer {
126
+ let buf = new ArrayBuffer(s.length);
127
+ let view = new Uint8Array(buf);
128
+ for (let i=0; i !== s.length; ++i) {
129
+ view[i] = s.charCodeAt(i) & 0xFF;
130
+ }
131
+ return buf;
132
+ };
133
+
134
+ export const removeColumns = function(dataArray:any[][], columnIndexes:number[]) {
135
+ const uniqueIndexes = [...new Set(columnIndexes)].sort().reverse();
136
+ uniqueIndexes.forEach(function(columnIndex) {
137
+ dataArray.forEach(function(row) {
138
+ row.splice(columnIndex, 1);
139
+ });
140
+ });
141
+ };
142
+
143
+ export const hasContent = function(value:any) : boolean {
144
+ return value !== undefined && value !== null && value !== "";
145
+ }
@@ -0,0 +1,56 @@
1
+ const assert = require('assert');
2
+
3
+ import ExcellentExport, { ConvertOptions, SheetOptions } from '../src/excellentexport';
4
+ import { PredefinedFormat } from '../src/format';
5
+
6
+
7
+ describe('convert() API with column formats', function() {
8
+
9
+ beforeEach(() => {
10
+ window.URL.createObjectURL = () => "blob:fake_URL";
11
+
12
+ document.body.innerHTML = '';
13
+ const element = document.createElement("div");
14
+ element.innerHTML = '<a id="anchor">Link</a>';
15
+
16
+ document.body.appendChild(element);
17
+ });
18
+
19
+ it('should create a XLSX with types', function() {
20
+ const options = {
21
+ anchor: 'anchor',
22
+ filename: 'data_from_array',
23
+ format: 'xlsx'
24
+ } as ConvertOptions;
25
+
26
+ const sheets = [
27
+ {
28
+ name: 'People',
29
+ from: {
30
+ array: [
31
+ ["ID", "Name", "Birthdate", "Active", "Salary"],
32
+ [11, "John", "1980-01-01", true, 1000.98],
33
+ [22, "Mary", "1985-02-02", false, 2000.88],
34
+ [33, "Peter", "1990-03-03", true, 3000.32],
35
+ ]
36
+ },
37
+ formats: [
38
+ { range: 'A2:A10', format: PredefinedFormat.INTEGER },
39
+ { range: 'C2:C10', format: PredefinedFormat.DATE },
40
+ { range: 'D2:D10', format: PredefinedFormat.BOOLEAN },
41
+ { range: 'E2:E10', format: PredefinedFormat.DECIMAL },
42
+ ]
43
+ },
44
+
45
+ ] as SheetOptions[];
46
+
47
+ const workbook = ExcellentExport.convert(options, sheets);
48
+
49
+ assert.ok(workbook, 'Result must not be null');
50
+
51
+ const anchor = document.getElementById('anchor') as HTMLAnchorElement;
52
+ assert.ok(anchor.href, 'Element must have href');
53
+ assert.ok(anchor.href.indexOf('blob:') === 0, 'Element href myst be a blob:');
54
+ });
55
+ });
56
+