1 | # ExcelJS
|
2 |
|
3 | Read, manipulate and write spreadsheet data and styles to XLSX and JSON.
|
4 |
|
5 | Reverse engineered from Excel spreadsheet files as a project.
|
6 |
|
7 | # Installation
|
8 |
|
9 | ```shell
|
10 | npm install exceljs.forked
|
11 | ```
|
12 |
|
13 | # New Features!
|
14 |
|
15 | <ul>
|
16 | <li>
|
17 | Merged <a href="https://github.com/guyonroche/exceljs/pull/466">Don't break when loading an Excel file containing a chartsheet #466</a>.
|
18 | Thanks to <a href="https://github.com/papandreou">Andreas Lind</a> for this contribution.
|
19 | </li>
|
20 | <li>
|
21 | Merged <a href="https://github.com/guyonroche/exceljs/pull/471">Hotfix/sheet order#257 #471</a>.
|
22 | This fixes <a href="https://github.com/guyonroche/exceljs/issues/257">Sheet Order #257</a>.
|
23 | Thanks to <a href="https://github.com/robbi">Robbi</a> for this contribution.
|
24 | </li>
|
25 | </ul>
|
26 |
|
27 | # Contributions
|
28 |
|
29 | Contributions are very welcome! It helps me know what features are desired or what bugs are causing the most pain.
|
30 |
|
31 | I have just one request; If you submit a pull request for a bugfix, please add a unit-test or integration-test (in the spec folder) that catches the problem.
|
32 | Even a PR that just has a failing test is fine - I can analyse what the test is doing and fix the code from that.
|
33 |
|
34 | To be clear, all contributions added to this library will be included in the library's MIT licence.
|
35 |
|
36 | # Notice
|
37 |
|
38 | I have to admit I'm still really snowed under at the moment and will not be able to
|
39 | pursue active development of exceljs in the coming months.
|
40 | I will however keep an eye on the pull requests and endeavour to merge and release
|
41 | them as they come.
|
42 |
|
43 | # Backlog
|
44 |
|
45 | <ul>
|
46 | <li>ESLint - slowly turn on (justifyable) rules which should, I hope, help make contributions easier.</li>
|
47 | <li>Conditional Formatting.</li>
|
48 | <li>There are still more print-settings to add; Fixed rows/cols, etc.</li>
|
49 | <li>XLSX Streaming Reader.</li>
|
50 | <li>Parsing CSV with Headers</li>
|
51 | </ul>
|
52 |
|
53 | # Contents
|
54 |
|
55 | <ul>
|
56 | <li>
|
57 | <a href="#interface">Interface</a>
|
58 | <ul>
|
59 | <li><a href="#create-a-workbook">Create a Workbook</a></li>
|
60 | <li><a href="#set-workbook-properties">Set Workbook Properties</a></li>
|
61 | <li><a href="#workbook-views">Workbook Views</a></li>
|
62 | <li><a href="#add-a-worksheet">Add a Worksheet</a></li>
|
63 | <li><a href="#remove-a-worksheet">Remove a Worksheet</a></li>
|
64 | <li><a href="#access-worksheets">Access Worksheets</a></li>
|
65 | <li><a href="#worksheet-properties">Worksheet Properties</a></li>
|
66 | <li><a href="#page-setup">Page Setup</a></li>
|
67 | <li>
|
68 | <a href="#worksheet-views">Worksheet Views</a>
|
69 | <ul>
|
70 | <li><a href="#frozen-views">Frozen Views</a></li>
|
71 | <li><a href="#split-views">Split Views</a></li>
|
72 | </ul>
|
73 | </li>
|
74 | <li><a href="#auto-filters">Auto Filters</a></li>
|
75 | <li><a href="#columns">Columns</a></li>
|
76 | <li><a href="#rows">Rows</a></li>
|
77 | <li><a href="#handling-individual-cells">Handling Individual Cells</a></li>
|
78 | <li><a href="#merged-cells">Merged Cells</a></li>
|
79 | <li><a href="#defined-names">Defined Names</a></li>
|
80 | <li><a href="#data-validations">Data Validations</a></li>
|
81 | <li><a href="#styles">Styles</a>
|
82 | <ul>
|
83 | <li><a href="#number-formats">Number Formats</a></li>
|
84 | <li><a href="#fonts">Fonts</a></li>
|
85 | <li><a href="#alignment">Alignment</a></li>
|
86 | <li><a href="#borders">Borders</a></li>
|
87 | <li><a href="#fills">Fills</a></li>
|
88 | <li><a href="#rich-text">Rich Text</a></li>
|
89 | </ul>
|
90 | </li>
|
91 | <li><a href="#outline-levels">Outline Levels</a></li>
|
92 | <li><a href="#images">Images</a></li>
|
93 | <li><a href="#file-io">File I/O</a>
|
94 | <ul>
|
95 | <li><a href="#xlsx">XLSX</a>
|
96 | <ul>
|
97 | <li><a href="#reading-xlsx">Reading XLSX</a></li>
|
98 | <li><a href="#writing-xlsx">Writing XLSX</a></li>
|
99 | </ul>
|
100 | </li>
|
101 | <li><a href="#csv">CSV</a>
|
102 | <ul>
|
103 | <li><a href="#reading-csv">Reading CSV</a></li>
|
104 | <li><a href="#writing-csv">Writing CSV</a></li>
|
105 | </ul>
|
106 | </li>
|
107 | <li><a href="#streaming-io">Streaming I/O</a>
|
108 | <ul>
|
109 | <li><a href="#reading-csv">Streaming XLSX</a></li>
|
110 | </ul>
|
111 | </li>
|
112 | </ul>
|
113 | </li>
|
114 | </ul>
|
115 | </li>
|
116 | <li><a href="#browser">Browser</a></li>
|
117 | <li>
|
118 | <a href="#value-types">Value Types</a>
|
119 | <ul>
|
120 | <li><a href="#null-value">Null Value</a></li>
|
121 | <li><a href="#merge-cell">Merge Cell</a></li>
|
122 | <li><a href="#number-value">Number Value</a></li>
|
123 | <li><a href="#string-value">String Value</a></li>
|
124 | <li><a href="#date-value">Date Value</a></li>
|
125 | <li><a href="#hyperlink-value">Hyperlink Value</a></li>
|
126 | <li>
|
127 | <a href="#formula-value">Formula Value</a>
|
128 | <ul>
|
129 | <li><a href="#shared-formula">Shared Formula</a></li>
|
130 | <li><a href="#formula-type">Formula Type</a></li>
|
131 | </ul>
|
132 | </li>
|
133 | <li><a href="#rich-text-value">Rich Text Value</a></li>
|
134 | <li><a href="#boolean-value">Boolean Value</a></li>
|
135 | <li><a href="#error-value">Error Value</a></li>
|
136 | </ul>
|
137 | </li>
|
138 | <li><a href="#config">Config</a></li>
|
139 | <li><a href="#known-issues">Known Issues</a></li>
|
140 | <li><a href="#release-history">Release History</a></li>
|
141 | </ul>
|
142 |
|
143 | # Interface
|
144 |
|
145 | ```javascript
|
146 | var Excel = require('exceljs');
|
147 | ```
|
148 |
|
149 | ## Create a Workbook
|
150 |
|
151 | ```javascript
|
152 | var workbook = new Excel.Workbook();
|
153 | ```
|
154 |
|
155 | ## Set Workbook Properties
|
156 |
|
157 | ```javascript
|
158 | workbook.creator = 'Me';
|
159 | workbook.lastModifiedBy = 'Her';
|
160 | workbook.created = new Date(1985, 8, 30);
|
161 | workbook.modified = new Date();
|
162 | workbook.lastPrinted = new Date(2016, 9, 27);
|
163 | ```
|
164 |
|
165 | ```javascript
|
166 | // Set workbook dates to 1904 date system
|
167 | workbook.properties.date1904 = true;
|
168 | ```
|
169 |
|
170 | ## Workbook Views
|
171 |
|
172 | The Workbook views controls how many separate windows Excel will open when viewing the workbook.
|
173 |
|
174 | ```javascript
|
175 | workbook.views = [
|
176 | {
|
177 | x: 0, y: 0, width: 10000, height: 20000,
|
178 | firstSheet: 0, activeTab: 1, visibility: 'visible'
|
179 | }
|
180 | ]
|
181 | ```
|
182 |
|
183 | ## Add a Worksheet
|
184 |
|
185 | ```javascript
|
186 | var sheet = workbook.addWorksheet('My Sheet');
|
187 | ```
|
188 |
|
189 | Use the second parameter of the addWorksheet function to specify options for the worksheet.
|
190 |
|
191 | For Example:
|
192 |
|
193 | ```javascript
|
194 | // create a sheet with red tab colour
|
195 | var sheet = workbook.addWorksheet('My Sheet', {properties:{tabColor:{argb:'FFC0000'}}});
|
196 |
|
197 | // create a sheet where the grid lines are hidden
|
198 | var sheet = workbook.addWorksheet('My Sheet', {properties: {showGridLines: false}});
|
199 |
|
200 | // create a sheet with the first row and column frozen
|
201 | var sheet = workbook.addWorksheet('My Sheet', {views:[{xSplit: 1, ySplit:1}]});
|
202 | ```
|
203 |
|
204 | ## Remove a Worksheet
|
205 |
|
206 | Use the worksheet `id` to remove the sheet from workbook.
|
207 |
|
208 | For Example:
|
209 |
|
210 | ```javascript
|
211 | // Create a worksheet
|
212 | var sheet = workbook.addWorksheet('My Sheet');
|
213 |
|
214 | // Remove the worksheet using worksheet id
|
215 | workbook.removeWorksheet(sheet.id)
|
216 | ```
|
217 |
|
218 | ## Access Worksheets
|
219 | ```javascript
|
220 | // Iterate over all sheets
|
221 | // Note: workbook.worksheets.forEach will still work but this is better
|
222 | workbook.eachSheet(function(worksheet, sheetId) {
|
223 | // ...
|
224 | });
|
225 |
|
226 | // fetch sheet by name
|
227 | var worksheet = workbook.getWorksheet('My Sheet');
|
228 |
|
229 | // fetch sheet by id
|
230 | var worksheet = workbook.getWorksheet(1);
|
231 | ```
|
232 |
|
233 | ## Worksheet Properties
|
234 |
|
235 | Worksheets support a property bucket to allow control over some features of the worksheet.
|
236 |
|
237 | ```javascript
|
238 | // create new sheet with properties
|
239 | var worksheet = workbook.addWorksheet('sheet', {properties:{tabColor:{argb:'FF00FF00'}}});
|
240 |
|
241 | // create a new sheet writer with properties
|
242 | var worksheetWriter = workbookWriter.addSheet('sheet', {properties:{outlineLevelCol:1}});
|
243 |
|
244 | // adjust properties afterwards (not supported by worksheet-writer)
|
245 | worksheet.properties.outlineLevelCol = 2;
|
246 | worksheet.properties.defaultRowHeight = 15;
|
247 | ```
|
248 |
|
249 | **Supported Properties**
|
250 |
|
251 | | Name | Default | Description |
|
252 | | ---------------- | ---------- | ----------- |
|
253 | | tabColor | undefined | Color of the tabs |
|
254 | | outlineLevelCol | 0 | The worksheet column outline level |
|
255 | | outlineLevelRow | 0 | The worksheet row outline level |
|
256 | | defaultRowHeight | 15 | Default row height |
|
257 | | dyDescent | 55 | TBD |
|
258 |
|
259 | ### Worksheet Metrics
|
260 |
|
261 | Some new metrics have been added to Worksheet...
|
262 |
|
263 | | Name | Description |
|
264 | | ----------------- | ----------- |
|
265 | | rowCount | The total row size of the document. Equal to the row number of the last row that has values. |
|
266 | | actualRowCount | A count of the number of rows that have values. If a mid-document row is empty, it will not be included in the count. |
|
267 | | columnCount | The total column size of the document. Equal to the maximum cell count from all of the rows |
|
268 | | actualColumnCount | A count of the number of columns that have values. |
|
269 |
|
270 |
|
271 | ## Page Setup
|
272 |
|
273 | All properties that can affect the printing of a sheet are held in a pageSetup object on the sheet.
|
274 |
|
275 | ```javascript
|
276 | // create new sheet with pageSetup settings for A4 - landscape
|
277 | var worksheet = workbook.addWorksheet('sheet', {
|
278 | pageSetup:{paperSize: 9, orientation:'landscape'}
|
279 | });
|
280 |
|
281 | // create a new sheet writer with pageSetup settings for fit-to-page
|
282 | var worksheetWriter = workbookWriter.addSheet('sheet', {
|
283 | pageSetup:{fitToPage: true, fitToHeight: 5, fitToWidth: 7}
|
284 | });
|
285 |
|
286 | // adjust pageSetup settings afterwards
|
287 | worksheet.pageSetup.margins = {
|
288 | left: 0.7, right: 0.7,
|
289 | top: 0.75, bottom: 0.75,
|
290 | header: 0.3, footer: 0.3
|
291 | };
|
292 |
|
293 | // Set Print Area for a sheet
|
294 | worksheet.pageSetup.printArea = 'A1:G20';
|
295 |
|
296 | // Repeat specific rows on every printed page
|
297 | worksheet.pageSetup.printTitlesRow = '1:3';
|
298 |
|
299 | ```
|
300 |
|
301 | **Supported pageSetup settings**
|
302 |
|
303 | | Name | Default | Description |
|
304 | | --------------------- | ------------- | ----------- |
|
305 | | margins | | Whitespace on the borders of the page. Units are inches. |
|
306 | | orientation | 'portrait' | Orientation of the page - i.e. taller (portrait) or wider (landscape) |
|
307 | | horizontalDpi | 4294967295 | Horizontal Dots per Inch. Default value is -1 |
|
308 | | verticalDpi | 4294967295 | Vertical Dots per Inch. Default value is -1 |
|
309 | | fitToPage | | Whether to use fitToWidth and fitToHeight or scale settings. Default is based on presence of these settings in the pageSetup object - if both are present, scale wins (i.e. default will be false) |
|
310 | | pageOrder | 'downThenOver'| Which order to print the pages - one of ['downThenOver', 'overThenDown'] |
|
311 | | blackAndWhite | false | Print without colour |
|
312 | | draft | false | Print with less quality (and ink) |
|
313 | | cellComments | 'None' | Where to place comments - one of ['atEnd', 'asDisplayed', 'None'] |
|
314 | | errors | 'displayed' | Where to show errors - one of ['dash', 'blank', 'NA', 'displayed'] |
|
315 | | scale | 100 | Percentage value to increase or reduce the size of the print. Active when fitToPage is false |
|
316 | | fitToWidth | 1 | How many pages wide the sheet should print on to. Active when fitToPage is true |
|
317 | | fitToHeight | 1 | How many pages high the sheet should print on to. Active when fitToPage is true |
|
318 | | paperSize | | What paper size to use (see below) |
|
319 | | showRowColHeaders | false | Whether to show the row numbers and column letters |
|
320 | | showGridLines | false | Whether to show grid lines |
|
321 | | firstPageNumber | | Which number to use for the first page |
|
322 | | horizontalCentered | false | Whether to center the sheet data horizontally |
|
323 | | verticalCentered | false | Whether to center the sheet data vertically |
|
324 |
|
325 | **Example Paper Sizes**
|
326 |
|
327 | | Name | Value |
|
328 | | ----------------------------- | --------- |
|
329 | | Letter | undefined |
|
330 | | Legal | 5 |
|
331 | | Executive | 7 |
|
332 | | A4 | 9 |
|
333 | | A5 | 11 |
|
334 | | B5 (JIS) | 13 |
|
335 | | Envelope #10 | 20 |
|
336 | | Envelope DL | 27 |
|
337 | | Envelope C5 | 28 |
|
338 | | Envelope B5 | 34 |
|
339 | | Envelope Monarch | 37 |
|
340 | | Double Japan Postcard Rotated | 82 |
|
341 | | 16K 197x273 mm | 119 |
|
342 |
|
343 | ## Worksheet Views
|
344 |
|
345 | Worksheets now support a list of views, that control how Excel presents the sheet:
|
346 |
|
347 | * frozen - where a number of rows and columns to the top and left are frozen in place. Only the bottom left section will scroll
|
348 | * split - where the view is split into 4 sections, each semi-independently scrollable.
|
349 |
|
350 | Each view also supports various properties:
|
351 |
|
352 | | Name | Default | Description |
|
353 | | ----------------- | --------- | ----------- |
|
354 | | state | 'normal' | Controls the view state - one of normal, frozen or split |
|
355 | | rightToLeft | false | Sets the worksheet view's orientation to right-to-left |
|
356 | | activeCell | undefined | The currently selected cell |
|
357 | | showRuler | true | Shows or hides the ruler in Page Layout |
|
358 | | showRowColHeaders | true | Shows or hides the row and column headers (e.g. A1, B1 at the top and 1,2,3 on the left |
|
359 | | showGridLines | true | Shows or hides the gridlines (shown for cells where borders have not been defined) |
|
360 | | zoomScale | 100 | Percentage zoom to use for the view |
|
361 | | zoomScaleNormal | 100 | Normal zoom for the view |
|
362 | | style | undefined | Presentation style - one of pageBreakPreview or pageLayout. Note pageLayout is not compatable with frozen views |
|
363 |
|
364 | ### Frozen Views
|
365 |
|
366 | Frozen views support the following extra properties:
|
367 |
|
368 | | Name | Default | Description |
|
369 | | ----------------- | --------- | ----------- |
|
370 | | xSplit | 0 | How many columns to freeze. To freeze rows only, set this to 0 or undefined |
|
371 | | ySplit | 0 | How many rows to freeze. To freeze columns only, set this to 0 or undefined |
|
372 | | topLeftCell | special | Which cell will be top-left in the bottom-right pane. Note: cannot be a frozen cell. Defaults to first unfrozen cell |
|
373 |
|
374 | ```javascript
|
375 | worksheet.views = [
|
376 | {state: 'frozen', xSplit: 2, ySplit: 3, topLeftCell: 'G10', activeCell: 'A1'}
|
377 | ];
|
378 | ```
|
379 |
|
380 | ### Split Views
|
381 |
|
382 | Split views support the following extra properties:
|
383 |
|
384 | | Name | Default | Description |
|
385 | | ----------------- | --------- | ----------- |
|
386 | | xSplit | 0 | How many points from the left to place the splitter. To split vertically, set this to 0 or undefined |
|
387 | | ySplit | 0 | How many points from the top to place the splitter. To split horizontally, set this to 0 or undefined |
|
388 | | topLeftCell | undefined | Which cell will be top-left in the bottom-right pane. |
|
389 | | activePane | undefined | Which pane will be active - one of topLeft, topRight, bottomLeft and bottomRight |
|
390 |
|
391 | ```javascript
|
392 | worksheet.views = [
|
393 | {state: 'split', xSplit: 2000, ySplit: 3000, topLeftCell: 'G10', activeCell: 'A1'}
|
394 | ];
|
395 | ```
|
396 |
|
397 | ## Auto filters
|
398 |
|
399 | It is possible to apply an auto filter to your worksheet.
|
400 |
|
401 | ```javascript
|
402 | worksheet.autoFilter = 'A1:C1';
|
403 | ```
|
404 |
|
405 | While the range string is the standard form of the autoFilter, the worksheet will also support the
|
406 | following values:
|
407 |
|
408 | ```javascript
|
409 | // Set an auto filter from A1 to C1
|
410 | worksheet.autoFilter = {
|
411 | from: 'A1',
|
412 | to: 'C1',
|
413 | }
|
414 |
|
415 | // Set an auto filter from the cell in row 3 and column 1
|
416 | // to the cell in row 5 and column 12
|
417 | worksheet.autoFilter = {
|
418 | from: {
|
419 | row: 3,
|
420 | column: 1
|
421 | },
|
422 | to: {
|
423 | row: 5,
|
424 | column: 12
|
425 | }
|
426 | }
|
427 |
|
428 | // Set an auto filter from D3 to the
|
429 | // cell in row 7 and column 5
|
430 | worksheet.autoFilter = {
|
431 | from: 'D3',
|
432 | to: {
|
433 | row: 7,
|
434 | column: 5
|
435 | }
|
436 | }
|
437 | ```
|
438 |
|
439 | ## Columns
|
440 |
|
441 | ```javascript
|
442 | // Add column headers and define column keys and widths
|
443 | // Note: these column structures are a workbook-building convenience only,
|
444 | // apart from the column width, they will not be fully persisted.
|
445 | worksheet.columns = [
|
446 | { header: 'Id', key: 'id', width: 10 },
|
447 | { header: 'Name', key: 'name', width: 32 },
|
448 | { header: 'D.O.B.', key: 'DOB', width: 10, outlineLevel: 1 }
|
449 | ];
|
450 |
|
451 | // Access an individual columns by key, letter and 1-based column number
|
452 | var idCol = worksheet.getColumn('id');
|
453 | var nameCol = worksheet.getColumn('B');
|
454 | var dobCol = worksheet.getColumn(3);
|
455 |
|
456 | // set column properties
|
457 |
|
458 | // Note: will overwrite cell value C1
|
459 | dobCol.header = 'Date of Birth';
|
460 |
|
461 | // Note: this will overwrite cell values C1:C2
|
462 | dobCol.header = ['Date of Birth', 'A.K.A. D.O.B.'];
|
463 |
|
464 | // from this point on, this column will be indexed by 'dob' and not 'DOB'
|
465 | dobCol.key = 'dob';
|
466 |
|
467 | dobCol.width = 15;
|
468 |
|
469 | // Hide the column if you'd like
|
470 | dobCol.hidden = true;
|
471 |
|
472 | // set an outline level for columns
|
473 | worksheet.getColumn(4).outlineLevel = 0;
|
474 | worksheet.getColumn(5).outlineLevel = 1;
|
475 |
|
476 | // columns support a readonly field to indicate the collapsed state based on outlineLevel
|
477 | expect(worksheet.getColumn(4).collapsed).to.equal(false);
|
478 | expect(worksheet.getColumn(5).collapsed).to.equal(true);
|
479 |
|
480 | // iterate over all current cells in this column
|
481 | dobCol.eachCell(function(cell, rowNumber) {
|
482 | // ...
|
483 | });
|
484 |
|
485 | // iterate over all current cells in this column including empty cells
|
486 | dobCol.eachCell({ includeEmpty: true }, function(cell, rowNumber) {
|
487 | // ...
|
488 | });
|
489 |
|
490 | // cut one or more columns (columns to the right are shifted left)
|
491 | // If column properties have been definde, they will be cut or moved accordingly
|
492 | // Known Issue: If a splice causes any merged cells to move, the results may be unpredictable
|
493 | worksheet.spliceColumns(3,2);
|
494 |
|
495 | // remove one column and insert two more.
|
496 | // Note: columns 4 and above will be shifted right by 1 column.
|
497 | // Also: If the worksheet has more rows than values in the colulmn inserts,
|
498 | // the rows will still be shifted as if the values existed
|
499 | var newCol3Values = [1,2,3,4,5];
|
500 | var newCol4Values = ['one', 'two', 'three', 'four', 'five'];
|
501 | worksheet.spliceColumns(3, 1, newCol3Values, newCol4Values);
|
502 |
|
503 | ```
|
504 |
|
505 | ## Rows
|
506 |
|
507 | ```javascript
|
508 | // Add a couple of Rows by key-value, after the last current row, using the column keys
|
509 | worksheet.addRow({id: 1, name: 'John Doe', dob: new Date(1970,1,1)});
|
510 | worksheet.addRow({id: 2, name: 'Jane Doe', dob: new Date(1965,1,7)});
|
511 |
|
512 | // Add a row by contiguous Array (assign to columns A, B & C)
|
513 | worksheet.addRow([3, 'Sam', new Date()]);
|
514 |
|
515 | // Add a row by sparse Array (assign to columns A, E & I)
|
516 | var rowValues = [];
|
517 | rowValues[1] = 4;
|
518 | rowValues[5] = 'Kyle';
|
519 | rowValues[9] = new Date();
|
520 | worksheet.addRow(rowValues);
|
521 |
|
522 | // Add an array of rows
|
523 | var rows = [
|
524 | [5,'Bob',new Date()], // row by array
|
525 | {id:6, name: 'Barbara', dob: new Date()}
|
526 | ];
|
527 | worksheet.addRows(rows);
|
528 |
|
529 | // Get a row object. If it doesn't already exist, a new empty one will be returned
|
530 | var row = worksheet.getRow(5);
|
531 |
|
532 | // Get the last editable row in a worksheet (or undefined if there are none)
|
533 | var row = worksheet.lastRow;
|
534 |
|
535 | // Set a specific row height
|
536 | row.height = 42.5;
|
537 |
|
538 | // make row hidden
|
539 | row.hidden = true;
|
540 |
|
541 | // set an outline level for rows
|
542 | worksheet.getRow(4).outlineLevel = 0;
|
543 | worksheet.getRow(5).outlineLevel = 1;
|
544 |
|
545 | // rows support a readonly field to indicate the collapsed state based on outlineLevel
|
546 | expect(worksheet.getRow(4).collapsed).to.equal(false);
|
547 | expect(worksheet.getRow(5).collapsed).to.equal(true);
|
548 |
|
549 |
|
550 | row.getCell(1).value = 5; // A5's value set to 5
|
551 | row.getCell('name').value = 'Zeb'; // B5's value set to 'Zeb' - assuming column 2 is still keyed by name
|
552 | row.getCell('C').value = new Date(); // C5's value set to now
|
553 |
|
554 | // Get a row as a sparse array
|
555 | // Note: interface change: worksheet.getRow(4) ==> worksheet.getRow(4).values
|
556 | row = worksheet.getRow(4).values;
|
557 | expect(row[5]).toEqual('Kyle');
|
558 |
|
559 | // assign row values by contiguous array (where array element 0 has a value)
|
560 | row.values = [1,2,3];
|
561 | expect(row.getCell(1).value).toEqual(1);
|
562 | expect(row.getCell(2).value).toEqual(2);
|
563 | expect(row.getCell(3).value).toEqual(3);
|
564 |
|
565 | // assign row values by sparse array (where array element 0 is undefined)
|
566 | var values = []
|
567 | values[5] = 7;
|
568 | values[10] = 'Hello, World!';
|
569 | row.values = values;
|
570 | expect(row.getCell(1).value).toBeNull();
|
571 | expect(row.getCell(5).value).toEqual(7);
|
572 | expect(row.getCell(10).value).toEqual('Hello, World!');
|
573 |
|
574 | // assign row values by object, using column keys
|
575 | row.values = {
|
576 | id: 13,
|
577 | name: 'Thing 1',
|
578 | dob: new Date()
|
579 | };
|
580 |
|
581 | // Insert a page break prior to the row
|
582 | row.addPageBreak();
|
583 |
|
584 | // Iterate over all rows that have values in a worksheet
|
585 | worksheet.eachRow(function(row, rowNumber) {
|
586 | console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
|
587 | });
|
588 |
|
589 | // Iterate over all rows (including empty rows) in a worksheet
|
590 | worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
|
591 | console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
|
592 | });
|
593 |
|
594 | // Iterate over all non-null cells in a row
|
595 | row.eachCell(function(cell, colNumber) {
|
596 | console.log('Cell ' + colNumber + ' = ' + cell.value);
|
597 | });
|
598 |
|
599 | // Iterate over all cells in a row (including empty cells)
|
600 | row.eachCell({ includeEmpty: true }, function(cell, colNumber) {
|
601 | console.log('Cell ' + colNumber + ' = ' + cell.value);
|
602 | });
|
603 |
|
604 | // Cut one or more rows (rows below are shifted up)
|
605 | // Known Issue: If a splice causes any merged cells to move, the results may be unpredictable
|
606 | worksheet.spliceRows(4,3);
|
607 |
|
608 | // remove one row and insert two more.
|
609 | // Note: rows 4 and below will be shifted down by 1 row.
|
610 | var newRow3Values = [1,2,3,4,5];
|
611 | var newRow4Values = ['one', 'two', 'three', 'four', 'five'];
|
612 | worksheet.spliceRows(3, 1, newRow3Values, newRow4Values);
|
613 |
|
614 | // Cut one or more cells (cells to the right are shifted left)
|
615 | // Note: this operation will not affect other rows
|
616 | row.splice(3,2);
|
617 |
|
618 | // remove one cell and insert two more (cells to the right of the cut cell will be shifted right)
|
619 | row.splice(4,1,'new value 1', 'new value 2');
|
620 |
|
621 | // Commit a completed row to stream
|
622 | row.commit();
|
623 |
|
624 | // row metrics
|
625 | var rowSize = row.cellCount;
|
626 | var numValues = row.actualCellCount;
|
627 | ```
|
628 |
|
629 | ## Handling Individual Cells
|
630 |
|
631 | ```javascript
|
632 | // Modify/Add individual cell
|
633 | worksheet.getCell('C3').value = new Date(1968, 5, 1);
|
634 |
|
635 | // query a cell's type
|
636 | expect(worksheet.getCell('C3').type).toEqual(Excel.ValueType.Date);
|
637 | ```
|
638 |
|
639 | ## Merged Cells
|
640 |
|
641 | ```javascript
|
642 | // merge a range of cells
|
643 | worksheet.mergeCells('A4:B5');
|
644 |
|
645 | // ... merged cells are linked
|
646 | worksheet.getCell('B5').value = 'Hello, World!';
|
647 | expect(worksheet.getCell('B5').value).toBe(worksheet.getCell('A4').value);
|
648 | expect(worksheet.getCell('B5').master).toBe(worksheet.getCell('A4'));
|
649 |
|
650 | // ... merged cells share the same style object
|
651 | expect(worksheet.getCell('B5').style).toBe(worksheet.getCell('A4').style);
|
652 | worksheet.getCell('B5').style.font = myFonts.arial;
|
653 | expect(worksheet.getCell('A4').style.font).toBe(myFonts.arial);
|
654 |
|
655 | // unmerging the cells breaks the style links
|
656 | worksheet.unMergeCells('A4');
|
657 | expect(worksheet.getCell('B5').style).not.toBe(worksheet.getCell('A4').style);
|
658 | expect(worksheet.getCell('B5').style.font).not.toBe(myFonts.arial);
|
659 |
|
660 | // merge by top-left, bottom-right
|
661 | worksheet.mergeCells('G10', 'H11');
|
662 | worksheet.mergeCells(10,11,12,13); // top,left,bottom,right
|
663 | ```
|
664 |
|
665 | ## Defined Names
|
666 |
|
667 | Individual cells (or multiple groups of cells) can have names assigned to them.
|
668 | The names can be used in formulas and data validation (and probably more).
|
669 |
|
670 | ```javascript
|
671 | // assign (or get) a name for a cell (will overwrite any other names that cell had)
|
672 | worksheet.getCell('A1').name = 'PI';
|
673 | expect(worksheet.getCell('A1').name).to.equal('PI');
|
674 |
|
675 | // assign (or get) an array of names for a cell (cells can have more than one name)
|
676 | worksheet.getCell('A1').names = ['thing1', 'thing2'];
|
677 | expect(worksheet.getCell('A1').names).to.have.members(['thing1', 'thing2']);
|
678 |
|
679 | // remove a name from a cell
|
680 | worksheet.getCell('A1').removeName('thing1');
|
681 | expect(worksheet.getCell('A1').names).to.have.members(['thing2']);
|
682 | ```
|
683 |
|
684 | ## Data Validations
|
685 |
|
686 | Cells can define what values are valid or not and provide prompting to the user to help guide them.
|
687 |
|
688 | Validation types can be one of the following:
|
689 |
|
690 | | Type | Description |
|
691 | | ---------- | ----------- |
|
692 | | list | Define a discrete set of valid values. Excel will offer these in a dropdown for easy entry |
|
693 | | whole | The value must be a whole number |
|
694 | | decimal | The value must be a decimal number |
|
695 | | textLength | The value may be text but the length is controlled |
|
696 | | custom | A custom formula controls the valid values |
|
697 |
|
698 | For types other than list or custom, the following operators affect the validation:
|
699 |
|
700 | | Operator | Description |
|
701 | | -------------------- | ----------- |
|
702 | | between | Values must lie between formula results |
|
703 | | notBetween | Values must not lie between formula results |
|
704 | | equal | Value must equal formula result |
|
705 | | notEqual | Value must not equal formula result |
|
706 | | greaterThan | Value must be greater than formula result |
|
707 | | lessThan | Value must be less than formula result |
|
708 | | greaterThanOrEqual | Value must be greater than or equal to formula result |
|
709 | | lessThanOrEqual | Value must be less than or equal to formula result |
|
710 |
|
711 | ```javascript
|
712 | // Specify list of valid values (One, Two, Three, Four).
|
713 | // Excel will provide a dropdown with these values.
|
714 | worksheet.getCell('A1').dataValidation = {
|
715 | type: 'list',
|
716 | allowBlank: true,
|
717 | formulae: ['"One,Two,Three,Four"']
|
718 | };
|
719 |
|
720 | // Specify list of valid values from a range.
|
721 | // Excel will provide a dropdown with these values.
|
722 | worksheet.getCell('A1').dataValidation = {
|
723 | type: 'list',
|
724 | allowBlank: true,
|
725 | formulae: ['$D$5:$F$5']
|
726 | };
|
727 |
|
728 | // Specify Cell must be a whole number that is not 5.
|
729 | // Show the user an appropriate error message if they get it wrong
|
730 | worksheet.getCell('A1').dataValidation = {
|
731 | type: 'whole',
|
732 | operator: 'notEqual',
|
733 | showErrorMessage: true,
|
734 | formulae: [5],
|
735 | errorStyle: 'error',
|
736 | errorTitle: 'Five',
|
737 | error: 'The value must not be Five'
|
738 | };
|
739 |
|
740 | // Specify Cell must be a decomal number between 1.5 and 7.
|
741 | // Add 'tooltip' to help guid the user
|
742 | worksheet.getCell('A1').dataValidation = {
|
743 | type: 'decimal',
|
744 | operator: 'between',
|
745 | allowBlank: true,
|
746 | showInputMessage: true,
|
747 | formulae: [1.5, 7],
|
748 | promptTitle: 'Decimal',
|
749 | prompt: 'The value must between 1.5 and 7'
|
750 | };
|
751 |
|
752 | // Specify Cell must be have a text length less than 15
|
753 | worksheet.getCell('A1').dataValidation = {
|
754 | type: 'textLength',
|
755 | operator: 'lessThan',
|
756 | showErrorMessage: true,
|
757 | allowBlank: true,
|
758 | formulae: [15]
|
759 | };
|
760 |
|
761 | // Specify Cell must be have be a date before 1st Jan 2016
|
762 | worksheet.getCell('A1').dataValidation = {
|
763 | type: 'date',
|
764 | operator: 'lessThan',
|
765 | showErrorMessage: true,
|
766 | allowBlank: true,
|
767 | formulae: [new Date(2016,0,1)]
|
768 | };
|
769 | ```
|
770 |
|
771 | ## Styles
|
772 |
|
773 | Cells, Rows and Columns each support a rich set of styles and formats that affect how the cells are displayed.
|
774 |
|
775 | Styles are set by assigning the following properties:
|
776 |
|
777 | * <a href="#number-formats">numFmt</a>
|
778 | * <a href="#fonts">font</a>
|
779 | * <a href="#alignment">alignment</a>
|
780 | * <a href="#borders">border</a>
|
781 | * <a href="#fills">fill</a>
|
782 |
|
783 | ```javascript
|
784 | // assign a style to a cell
|
785 | ws.getCell('A1').numFmt = '0.00%';
|
786 |
|
787 | // Apply styles to worksheet columns
|
788 | ws.columns = [
|
789 | { header: 'Id', key: 'id', width: 10 },
|
790 | { header: 'Name', key: 'name', width: 32, style: { font: { name: 'Arial Black' } } },
|
791 | { header: 'D.O.B.', key: 'DOB', width: 10, style: { numFmt: 'dd/mm/yyyy' } }
|
792 | ];
|
793 |
|
794 | // Set Column 3 to Currency Format
|
795 | ws.getColumn(3).numFmt = '"£"#,##0.00;[Red]\-"£"#,##0.00';
|
796 |
|
797 | // Set Row 2 to Comic Sans.
|
798 | ws.getRow(2).font = { name: 'Comic Sans MS', family: 4, size: 16, underline: 'double', bold: true };
|
799 | ```
|
800 |
|
801 | When a style is applied to a row or column, it will be applied to all currently existing cells in that row or column.
|
802 | Also, any new cell that is created will inherit its initial styles from the row and column it belongs to.
|
803 |
|
804 | If a cell's row and column both define a specific style (e.g. font), the cell will use the row style over the column style.
|
805 | However if the row and column define different styles (e.g. column.numFmt and row.font), the cell will inherit the font from the row and the numFmt from the column.
|
806 |
|
807 | Caveat: All the above properties (with the exception of numFmt, which is a string), are JS object structures.
|
808 | If the same style object is assigned to more than one spreadsheet entity, then each entity will share the same style object.
|
809 | If the style object is later modified before the spreadsheet is serialized, then all entities referencing that style object will be modified too.
|
810 | This behaviour is intended to prioritize performance by reducing the number of JS objects created.
|
811 | If you want the style objects to be independent, you will need to clone them before assigning them.
|
812 | Also, by default, when a document is read from file (or stream) if spreadsheet entities share similar styles, then they will reference the same style object too.
|
813 |
|
814 | ### Number Formats
|
815 |
|
816 | ```javascript
|
817 | // display value as '1 3/5'
|
818 | ws.getCell('A1').value = 1.6;
|
819 | ws.getCell('A1').numFmt = '# ?/?';
|
820 |
|
821 | // display value as '1.60%'
|
822 | ws.getCell('B1').value = 0.016;
|
823 | ws.getCell('B1').numFmt = '0.00%';
|
824 | ```
|
825 |
|
826 | ### Fonts
|
827 |
|
828 | ```javascript
|
829 |
|
830 | // for the wannabe graphic designers out there
|
831 | ws.getCell('A1').font = {
|
832 | name: 'Comic Sans MS',
|
833 | family: 4,
|
834 | size: 16,
|
835 | underline: true,
|
836 | bold: true
|
837 | };
|
838 |
|
839 | // for the graduate graphic designers...
|
840 | ws.getCell('A2').font = {
|
841 | name: 'Arial Black',
|
842 | color: { argb: 'FF00FF00' },
|
843 | family: 2,
|
844 | size: 14,
|
845 | italic: true
|
846 | };
|
847 |
|
848 | // note: the cell will store a reference to the font object assigned.
|
849 | // If the font object is changed afterwards, the cell font will change also...
|
850 | var font = { name: 'Arial', size: 12 };
|
851 | ws.getCell('A3').font = font;
|
852 | font.size = 20; // Cell A3 now has font size 20!
|
853 |
|
854 | // Cells that share similar fonts may reference the same font object after
|
855 | // the workbook is read from file or stream
|
856 | ```
|
857 |
|
858 | | Font Property | Description | Example Value(s) |
|
859 | | ------------- | ----------------- | ---------------- |
|
860 | | name | Font name. | 'Arial', 'Calibri', etc. |
|
861 | | family | Font family for fallback. An integer value. | 1 - Serif, 2 - Sans Serif, 3 - Mono, Others - unknown |
|
862 | | scheme | Font scheme. | 'minor', 'major', 'none' |
|
863 | | charset | Font charset. An integer value. | 1, 2, etc. |
|
864 | | color | Colour description, an object containing an ARGB value. | { argb: 'FFFF0000'} |
|
865 | | bold | Font **weight** | true, false |
|
866 | | italic | Font *slope* | true, false |
|
867 | | underline | Font <u>underline</u> style | true, false, 'none', 'single', 'double', 'singleAccounting', 'doubleAccounting' |
|
868 | | strike | Font <strike>strikethrough</strike> | true, false |
|
869 | | outline | Font outline | true, false |
|
870 |
|
871 | ### Alignment
|
872 |
|
873 | ```javascript
|
874 | // set cell alignment to top-left, middle-center, bottom-right
|
875 | ws.getCell('A1').alignment = { vertical: 'top', horizontal: 'left' };
|
876 | ws.getCell('B1').alignment = { vertical: 'middle', horizontal: 'center' };
|
877 | ws.getCell('C1').alignment = { vertical: 'bottom', horizontal: 'right' };
|
878 |
|
879 | // set cell to wrap-text
|
880 | ws.getCell('D1').alignment = { wrapText: true };
|
881 |
|
882 | // set cell indent to 1
|
883 | ws.getCell('E1').alignment = { indent: 1 };
|
884 |
|
885 | // set cell text rotation to 30deg upwards, 45deg downwards and vertical text
|
886 | ws.getCell('F1').alignment = { textRotation: 30 };
|
887 | ws.getCell('G1').alignment = { textRotation: -45 };
|
888 | ws.getCell('H1').alignment = { textRotation: 'vertical' };
|
889 | ```
|
890 |
|
891 | **Valid Alignment Property Values**
|
892 |
|
893 | | horizontal | vertical | wrapText | indent | readingOrder | textRotation |
|
894 | | ---------------- | ----------- | -------- | ------- | ------------ | ------------ |
|
895 | | left | top | true | integer | rtl | 0 to 90 |
|
896 | | center | middle | false | | ltr | -1 to -90 |
|
897 | | right | bottom | | | | vertical |
|
898 | | fill | distributed | | | | |
|
899 | | justify | justify | | | | |
|
900 | | centerContinuous | | | | | |
|
901 | | distributed | | | | | |
|
902 |
|
903 |
|
904 | ### Borders
|
905 |
|
906 | ```javascript
|
907 | // set single thin border around A1
|
908 | ws.getCell('A1').border = {
|
909 | top: {style:'thin'},
|
910 | left: {style:'thin'},
|
911 | bottom: {style:'thin'},
|
912 | right: {style:'thin'}
|
913 | };
|
914 |
|
915 | // set double thin green border around A3
|
916 | ws.getCell('A3').border = {
|
917 | top: {style:'double', color: {argb:'FF00FF00'}},
|
918 | left: {style:'double', color: {argb:'FF00FF00'}},
|
919 | bottom: {style:'double', color: {argb:'FF00FF00'}},
|
920 | right: {style:'double', color: {argb:'FF00FF00'}}
|
921 | };
|
922 |
|
923 | // set thick red cross in A5
|
924 | ws.getCell('A5').border = {
|
925 | diagonal: {up: true, down: true, style:'thick', color: {argb:'FFFF0000'}}
|
926 | };
|
927 | ```
|
928 |
|
929 | **Valid Border Styles**
|
930 |
|
931 | * thin
|
932 | * dotted
|
933 | * dashDot
|
934 | * hair
|
935 | * dashDotDot
|
936 | * slantDashDot
|
937 | * mediumDashed
|
938 | * mediumDashDotDot
|
939 | * mediumDashDot
|
940 | * medium
|
941 | * double
|
942 | * thick
|
943 |
|
944 | ### Fills
|
945 |
|
946 | ```javascript
|
947 | // fill A1 with red darkVertical stripes
|
948 | ws.getCell('A1').fill = {
|
949 | type: 'pattern',
|
950 | pattern:'darkVertical',
|
951 | fgColor:{argb:'FFFF0000'}
|
952 | };
|
953 |
|
954 | // fill A2 with yellow dark trellis and blue behind
|
955 | ws.getCell('A2').fill = {
|
956 | type: 'pattern',
|
957 | pattern:'darkTrellis',
|
958 | fgColor:{argb:'FFFFFF00'},
|
959 | bgColor:{argb:'FF0000FF'}
|
960 | };
|
961 |
|
962 | // fill A3 with blue-white-blue gradient from left to right
|
963 | ws.getCell('A3').fill = {
|
964 | type: 'gradient',
|
965 | gradient: 'angle',
|
966 | degree: 0,
|
967 | stops: [
|
968 | {position:0, color:{argb:'FF0000FF'}},
|
969 | {position:0.5, color:{argb:'FFFFFFFF'}},
|
970 | {position:1, color:{argb:'FF0000FF'}}
|
971 | ]
|
972 | };
|
973 |
|
974 |
|
975 | // fill A4 with red-green gradient from center
|
976 | ws.getCell('A2').fill = {
|
977 | type: 'gradient',
|
978 | gradient: 'path',
|
979 | center:{left:0.5,top:0.5},
|
980 | stops: [
|
981 | {position:0, color:{argb:'FFFF0000'}},
|
982 | {position:1, color:{argb:'FF00FF00'}}
|
983 | ]
|
984 | };
|
985 | ```
|
986 |
|
987 | #### Pattern Fills
|
988 |
|
989 | | Property | Required | Description |
|
990 | | -------- | -------- | ----------- |
|
991 | | type | Y | Value: 'pattern'<br/>Specifies this fill uses patterns |
|
992 | | pattern | Y | Specifies type of pattern (see <a href="#valid-pattern-types">Valid Pattern Types</a> below) |
|
993 | | fgColor | N | Specifies the pattern foreground color. Default is black. |
|
994 | | bgColor | N | Specifies the pattern background color. Default is white. |
|
995 |
|
996 | **Valid Pattern Types**
|
997 |
|
998 | * none
|
999 | * solid
|
1000 | * darkVertical
|
1001 | * darkGray
|
1002 | * mediumGray
|
1003 | * lightGray
|
1004 | * gray125
|
1005 | * gray0625
|
1006 | * darkHorizontal
|
1007 | * darkVertical
|
1008 | * darkDown
|
1009 | * darkUp
|
1010 | * darkGrid
|
1011 | * darkTrellis
|
1012 | * lightHorizontal
|
1013 | * lightVertical
|
1014 | * lightDown
|
1015 | * lightUp
|
1016 | * lightGrid
|
1017 | * lightTrellis
|
1018 | * lightGrid
|
1019 |
|
1020 | #### Gradient Fills
|
1021 |
|
1022 | | Property | Required | Description |
|
1023 | | -------- | -------- | ----------- |
|
1024 | | type | Y | Value: 'gradient'<br/>Specifies this fill uses gradients |
|
1025 | | gradient | Y | Specifies gradient type. One of ['angle', 'path'] |
|
1026 | | degree | angle | For 'angle' gradient, specifies the direction of the gradient. 0 is from the left to the right. Values from 1 - 359 rotates the direction clockwise |
|
1027 | | center | path | For 'path' gradient. Specifies the relative coordinates for the start of the path. 'left' and 'top' values range from 0 to 1 |
|
1028 | | stops | Y | Specifies the gradient colour sequence. Is an array of objects containing position and color starting with position 0 and ending with position 1. Intermediary positions may be used to specify other colours on the path. |
|
1029 |
|
1030 | **Caveats**
|
1031 |
|
1032 | Using the interface above it may be possible to create gradient fill effects not possible using the XLSX editor program.
|
1033 | For example, Excel only supports angle gradients of 0, 45, 90 and 135.
|
1034 | 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.
|
1035 | Take care with this fill to be sure it is supported by the target XLSX viewers.
|
1036 |
|
1037 | #### Rich Text
|
1038 |
|
1039 | Individual cells now support rich text or in-cell formatting.
|
1040 | Rich text values can control the font properties of any number of sub-strings within the text value.
|
1041 | See <a href="font">Fonts</a> for a complete list of details on what font properties are supported.
|
1042 |
|
1043 | ```javascript
|
1044 |
|
1045 | ws.getCell('A1').value = {
|
1046 | 'richText': [
|
1047 | {'font': {'size': 12,'color': {'theme': 0},'name': 'Calibri','family': 2,'scheme': 'minor'},'text': 'This is '},
|
1048 | {'font': {'italic': true,'size': 12,'color': {'theme': 0},'name': 'Calibri','scheme': 'minor'},'text': 'a'},
|
1049 | {'font': {'size': 12,'color': {'theme': 1},'name': 'Calibri','family': 2,'scheme': 'minor'},'text': ' '},
|
1050 | {'font': {'size': 12,'color': {'argb': 'FFFF6600'},'name': 'Calibri','scheme': 'minor'},'text': 'colorful'},
|
1051 | {'font': {'size': 12,'color': {'theme': 1},'name': 'Calibri','family': 2,'scheme': 'minor'},'text': ' text '},
|
1052 | {'font': {'size': 12,'color': {'argb': 'FFCCFFCC'},'name': 'Calibri','scheme': 'minor'},'text': 'with'},
|
1053 | {'font': {'size': 12,'color': {'theme': 1},'name': 'Calibri','family': 2,'scheme': 'minor'},'text': ' in-cell '},
|
1054 | {'font': {'bold': true,'size': 12,'color': {'theme': 1},'name': 'Calibri','family': 2,'scheme': 'minor'},'text': 'format'}
|
1055 | ]
|
1056 | };
|
1057 |
|
1058 | expect(ws.getCell('A1').text).to.equal('This is a colorful text with in-cell format');
|
1059 | expect(ws.getCell('A1').type).to.equal(Excel.ValueType.RichText);
|
1060 |
|
1061 | ```
|
1062 |
|
1063 | ## Outline Levels
|
1064 |
|
1065 | Excel supports outlining; where rows or columns can be expanded or collapsed depending on what level of detail the user wishes to view.
|
1066 |
|
1067 | Outline levels can be defined in column setup:
|
1068 | ```javascript
|
1069 | worksheet.columns = [
|
1070 | { header: 'Id', key: 'id', width: 10 },
|
1071 | { header: 'Name', key: 'name', width: 32 },
|
1072 | { header: 'D.O.B.', key: 'DOB', width: 10, outlineLevel: 1 }
|
1073 | ];
|
1074 | ```
|
1075 |
|
1076 | Or directly on the row or column
|
1077 | ```javascript
|
1078 | worksheet.getColumn(3).outlineLevel = 1;
|
1079 | worksheet.getRow(3).outlineLevel = 1;
|
1080 | ```
|
1081 |
|
1082 | The sheet outline levels can be set on the worksheet
|
1083 | ```javascript
|
1084 | // set column outline level
|
1085 | worksheet.properties.outlineLevelCol = 1;
|
1086 |
|
1087 | // set row outline level
|
1088 | worksheet.properties.outlineLevelRow = 1;
|
1089 | ```
|
1090 |
|
1091 | Note: adjusting outline levels on rows or columns or the outline levels on the worksheet will incur a side effect of also modifying the collapsed property of all rows or columns affected by the property change. E.g.:
|
1092 | ```javascript
|
1093 | worksheet.properties.outlineLevelCol = 1;
|
1094 |
|
1095 | worksheet.getColumn(3).outlineLevel = 1;
|
1096 | expect(worksheet.getColumn(3).collapsed).to.be.true;
|
1097 |
|
1098 | worksheet.properties.outlineLevelCol = 2;
|
1099 | expect(worksheet.getColumn(3).collapsed).to.be.false;
|
1100 | ```
|
1101 |
|
1102 | ## Images
|
1103 |
|
1104 | Adding images to a worksheet is a two-step process.
|
1105 | First, the image is added to the workbook via the addImage() function which will also return an imageId value.
|
1106 | Then, using the imageId, the image can be added to the worksheet either as a tiled background or covering a cell range.
|
1107 |
|
1108 | Note: As of this version, adjusting or transforming the image is not supported.
|
1109 |
|
1110 | ### Add Image to Workbook
|
1111 |
|
1112 | The Workbook.addImage function supports adding images by filename or by Buffer.
|
1113 | Note that in both cases, the extension must be specified.
|
1114 | Valid extension values include 'jpeg', 'png', 'gif'.
|
1115 |
|
1116 | ```javascript
|
1117 | // add image to workbook by filename
|
1118 | var imageId1 = workbook.addImage({
|
1119 | filename: 'path/to/image.jpg',
|
1120 | extension: 'jpeg',
|
1121 | });
|
1122 |
|
1123 | // add image to workbook by buffer
|
1124 | var imageId2 = workbook.addImage({
|
1125 | buffer: fs.readFileSync('path/to.image.png'),
|
1126 | extension: 'png',
|
1127 | });
|
1128 |
|
1129 | // add image to workbook by base64
|
1130 | var myBase64Image = "data:image/png;base64,iVBORw0KG...";
|
1131 | var imageId2 = workbook.addImage({
|
1132 | base64: myBase64Image,
|
1133 | extension: 'png',
|
1134 | });
|
1135 | ```
|
1136 |
|
1137 | ### Add image background to worksheet
|
1138 |
|
1139 | Using the image id from Workbook.addImage, the background to a worksheet can be set using the addBackgroundImage function
|
1140 |
|
1141 | ```javascript
|
1142 | // set background
|
1143 | worksheet.addBackgroundImage(imageId1);
|
1144 | ```
|
1145 |
|
1146 | ### Add image over a range
|
1147 |
|
1148 | Using the image id from Workbook.addImage, an image can be embedded within the worksheet to cover a range.
|
1149 | The coordinates calculated from the range will cover from the top-left of the first cell to the bottom right of the second.
|
1150 |
|
1151 | ```javascript
|
1152 | // insert an image over B2:D6
|
1153 | worksheet.addImage(imageId2, 'B2:D6');
|
1154 | ```
|
1155 |
|
1156 | Using a structure instead of a range string, it is possible to partially cover cells.
|
1157 |
|
1158 | Note that the coordinate system used for this is zero based, so the top-left of A1 will be { col: 0, row: 0 }.
|
1159 | Fractions of cells can be specified by using floating point numbers, e.g. the midpoint of A1 is { col: 0.5, row: 0.5 }.
|
1160 |
|
1161 | ```javascript
|
1162 | // insert an image over part of B2:D6
|
1163 | worksheet.addImage(imageId2, {
|
1164 | tl: { col: 1.5, row: 1.5 },
|
1165 | br: { col: 3.5, row: 5.5 }
|
1166 | });
|
1167 | ```
|
1168 |
|
1169 | The cell range can also have the eproperty 'editAs' which will control how the image is anchored to the cell(s)
|
1170 | It can have one of the following values:
|
1171 |
|
1172 | | Value | Description |
|
1173 | | --------- | ----------- |
|
1174 | | undefined | This is the default. It specifies the image will be moved and sized with cells |
|
1175 | | oneCell | Image will be moved with cells but not sized |
|
1176 | | absolute | Image will not be moved or sized with cells |
|
1177 |
|
1178 | ```javascript
|
1179 | ws.addImage(imageId, {
|
1180 | tl: { col: 0.1125, row: 0.4 },
|
1181 | br: { col: 2.101046875, row: 3.4 },
|
1182 | editAs: 'oneCell'
|
1183 | });
|
1184 | ```
|
1185 |
|
1186 | ## File I/O
|
1187 |
|
1188 | ### XLSX
|
1189 |
|
1190 | #### Reading XLSX
|
1191 |
|
1192 | ```javascript
|
1193 | // read from a file
|
1194 | var workbook = new Excel.Workbook();
|
1195 | workbook.xlsx.readFile(filename)
|
1196 | .then(function() {
|
1197 | // use workbook
|
1198 | });
|
1199 |
|
1200 | // pipe from stream
|
1201 | var workbook = new Excel.Workbook();
|
1202 | stream.pipe(workbook.xlsx.createInputStream());
|
1203 | ```
|
1204 |
|
1205 | #### Writing XLSX
|
1206 |
|
1207 | ```javascript
|
1208 | // write to a file
|
1209 | var workbook = createAndFillWorkbook();
|
1210 | workbook.xlsx.writeFile(filename)
|
1211 | .then(function() {
|
1212 | // done
|
1213 | });
|
1214 |
|
1215 | // write to a stream
|
1216 | workbook.xlsx.write(stream)
|
1217 | .then(function() {
|
1218 | // done
|
1219 | });
|
1220 | ```
|
1221 |
|
1222 | ### CSV
|
1223 |
|
1224 | #### Reading CSV
|
1225 |
|
1226 | ```javascript
|
1227 | // read from a file
|
1228 | var workbook = new Excel.Workbook();
|
1229 | workbook.csv.readFile(filename)
|
1230 | .then(function(worksheet) {
|
1231 | // use workbook or worksheet
|
1232 | });
|
1233 |
|
1234 | // read from a stream
|
1235 | var workbook = new Excel.Workbook();
|
1236 | workbook.csv.read(stream)
|
1237 | .then(function(worksheet) {
|
1238 | // use workbook or worksheet
|
1239 | });
|
1240 |
|
1241 | // pipe from stream
|
1242 | var workbook = new Excel.Workbook();
|
1243 | stream.pipe(workbook.csv.createInputStream());
|
1244 |
|
1245 | // read from a file with European Dates
|
1246 | var workbook = new Excel.Workbook();
|
1247 | var options = {
|
1248 | dateFormats: ['DD/MM/YYYY']
|
1249 | };
|
1250 | workbook.csv.readFile(filename, options)
|
1251 | .then(function(worksheet) {
|
1252 | // use workbook or worksheet
|
1253 | });
|
1254 |
|
1255 | // read from a file with custom value parsing
|
1256 | var workbook = new Excel.Workbook();
|
1257 | var options = {
|
1258 | map: function(value, index) {
|
1259 | switch(index) {
|
1260 | case 0:
|
1261 | // column 1 is string
|
1262 | return value;
|
1263 | case 1:
|
1264 | // column 2 is a date
|
1265 | return new Date(value);
|
1266 | case 2:
|
1267 | // column 3 is JSON of a formula value
|
1268 | return JSON.parse(value);
|
1269 | default:
|
1270 | // the rest are numbers
|
1271 | return parseFloat(value);
|
1272 | }
|
1273 | }
|
1274 | };
|
1275 | workbook.csv.readFile(filename, options)
|
1276 | .then(function(worksheet) {
|
1277 | // use workbook or worksheet
|
1278 | });
|
1279 | ```
|
1280 |
|
1281 | The CSV parser uses [fast-csv](https://www.npmjs.com/package/fast-csv) to read the CSV file.
|
1282 | The options passed into the read functions above is also passed to fast-csv for parsing of the csv data.
|
1283 | Please refer to the fast-csv README.md for details.
|
1284 |
|
1285 | Dates are parsed using the npm module [moment](https://www.npmjs.com/package/moment).
|
1286 | If no dateFormats are supplied, the following are used:
|
1287 |
|
1288 | * moment.ISO_8601
|
1289 | * 'MM-DD-YYYY'
|
1290 | * 'YYYY-MM-DD'
|
1291 |
|
1292 | #### Writing CSV
|
1293 |
|
1294 | ```javascript
|
1295 |
|
1296 | // write to a file
|
1297 | var workbook = createAndFillWorkbook();
|
1298 | workbook.csv.writeFile(filename)
|
1299 | .then(function() {
|
1300 | // done
|
1301 | });
|
1302 |
|
1303 | // write to a stream
|
1304 | // Be careful that you need to provide sheetName or
|
1305 | // sheetId for correct import to csv.
|
1306 | workbook.csv.write(stream, { sheetName: 'Page name' })
|
1307 | .then(function() {
|
1308 | // done
|
1309 | });
|
1310 |
|
1311 | // read from a file with European Date-Times
|
1312 | var workbook = new Excel.Workbook();
|
1313 | var options = {
|
1314 | dateFormat: 'DD/MM/YYYY HH:mm:ss'
|
1315 | };
|
1316 | workbook.csv.readFile(filename, options)
|
1317 | .then(function(worksheet) {
|
1318 | // use workbook or worksheet
|
1319 | });
|
1320 |
|
1321 |
|
1322 | // read from a file with custom value formatting
|
1323 | var workbook = new Excel.Workbook();
|
1324 | var options = {
|
1325 | map: function(value, index) {
|
1326 | switch(index) {
|
1327 | case 0:
|
1328 | // column 1 is string
|
1329 | return value;
|
1330 | case 1:
|
1331 | // column 2 is a date
|
1332 | return moment(value).format('YYYY-MM-DD');
|
1333 | case 2:
|
1334 | // column 3 is a formula, write just the result
|
1335 | return value.result;
|
1336 | default:
|
1337 | // the rest are numbers
|
1338 | return value;
|
1339 | }
|
1340 | }
|
1341 | };
|
1342 | workbook.csv.readFile(filename, options)
|
1343 | .then(function(worksheet) {
|
1344 | // use workbook or worksheet
|
1345 | });
|
1346 | ```
|
1347 |
|
1348 | The CSV parser uses [fast-csv](https://www.npmjs.com/package/fast-csv) to write the CSV file.
|
1349 | The options passed into the write functions above is also passed to fast-csv for writing the csv data.
|
1350 | Please refer to the fast-csv README.md for details.
|
1351 |
|
1352 | Dates are formatted using the npm module [moment](https://www.npmjs.com/package/moment).
|
1353 | If no dateFormat is supplied, moment.ISO_8601 is used.
|
1354 |
|
1355 | ### Streaming I/O
|
1356 |
|
1357 | The File I/O documented above requires that an entire workbook is built up in memory before the file can be written.
|
1358 | While convenient, it can limit the size of the document due to the amount of memory required.
|
1359 |
|
1360 | A streaming writer (or reader) processes the workbook or worksheet data as it is generated,
|
1361 | converting it into file form as it goes. Typically this is much more efficient on memory as the final
|
1362 | memory footprint and even intermediate memory footprints are much more compact than with the document version,
|
1363 | especially when you consider that the row and cell objects are disposed once they are committed.
|
1364 |
|
1365 | The interface to the streaming workbook and worksheet is almost the same as the document versions with a few minor practical differences:
|
1366 |
|
1367 | * Once a worksheet is added to a workbook, it cannot be removed.
|
1368 | * Once a row is committed, it is no longer accessible since it will have been dropped from the worksheet.
|
1369 | * unMergeCells() is not supported.
|
1370 |
|
1371 | Note that it is possible to build the entire workbook without committing any rows.
|
1372 | When the workbook is committed, all added worksheets (including all uncommitted rows) will be automatically committed.
|
1373 | However in this case, little will have been gained over the Document version.
|
1374 |
|
1375 | #### Streaming XLSX
|
1376 |
|
1377 | ##### Streaming XLSX Writer
|
1378 |
|
1379 | The streaming XLSX writer is available in the ExcelJS.stream.xlsx namespace.
|
1380 |
|
1381 | The constructor takes an optional options object with the following fields:
|
1382 |
|
1383 | | Field | Description |
|
1384 | | ---------------- | ----------- |
|
1385 | | stream | Specifies a writable stream to write the XLSX workbook to. |
|
1386 | | filename | If stream not specified, this field specifies the path to a file to write the XLSX workbook to. |
|
1387 | | useSharedStrings | Specifies whether to use shared strings in the workbook. Default is false |
|
1388 | | useStyles | Specifies whether to add style information to the workbook. Styles can add some performance overhead. Default is false |
|
1389 |
|
1390 | If neither stream nor filename is specified in the options, the workbook writer will create a StreamBuf object
|
1391 | that will store the contents of the XLSX workbook in memory.
|
1392 | This StreamBuf object, which can be accessed via the property workbook.stream, can be used to either
|
1393 | access the bytes directly by stream.read() or to pipe the contents to another stream.
|
1394 |
|
1395 | ```javascript
|
1396 | // construct a streaming XLSX workbook writer with styles and shared strings
|
1397 | var options = {
|
1398 | filename: './streamed-workbook.xlsx',
|
1399 | useStyles: true,
|
1400 | useSharedStrings: true
|
1401 | };
|
1402 | var workbook = new Excel.stream.xlsx.WorkbookWriter(options);
|
1403 | ```
|
1404 |
|
1405 | In general, the interface to the streaming XLSX writer is the same as the Document workbook (and worksheets)
|
1406 | described above, in fact the row, cell and style objects are the same.
|
1407 |
|
1408 | However there are some differences...
|
1409 |
|
1410 | **Construction**
|
1411 |
|
1412 | As seen above, the WorkbookWriter will typically require the output stream or file to be specified in the constructor.
|
1413 |
|
1414 | **Committing Data**
|
1415 |
|
1416 | When a worksheet row is ready, it should be committed so that the row object and contents can be freed.
|
1417 | Typically this would be done as each row is added...
|
1418 |
|
1419 | ```javascript
|
1420 | worksheet.addRow({
|
1421 | id: i,
|
1422 | name: theName,
|
1423 | etc: someOtherDetail
|
1424 | }).commit();
|
1425 | ```
|
1426 |
|
1427 | The reason the WorksheetWriter does not commit rows as they are added is to allow cells to be merged across rows:
|
1428 | ```javascript
|
1429 | worksheet.mergeCells('A1:B2');
|
1430 | worksheet.getCell('A1').value = 'I am merged';
|
1431 | worksheet.getCell('C1').value = 'I am not';
|
1432 | worksheet.getCell('C2').value = 'Neither am I';
|
1433 | worksheet.getRow(2).commit(); // now rows 1 and two are committed.
|
1434 | ```
|
1435 |
|
1436 | As each worksheet is completed, it must also be committed:
|
1437 |
|
1438 | ```javascript
|
1439 | // Finished adding data. Commit the worksheet
|
1440 | worksheet.commit();
|
1441 | ```
|
1442 |
|
1443 | To complete the XLSX document, the workbook must be committed. If any worksheet in a workbook are uncommitted,
|
1444 | they will be committed automatically as part of the workbook commit.
|
1445 |
|
1446 | ```javascript
|
1447 | // Finished the workbook.
|
1448 | workbook.commit()
|
1449 | .then(function() {
|
1450 | // the stream has been written
|
1451 | });
|
1452 | ```
|
1453 |
|
1454 | # Browser
|
1455 |
|
1456 | A portion of this library has been isolated and tested for use within a browser environment.
|
1457 |
|
1458 | Due to the streaming nature of the workbook reader and workbook writer, these have not been included.
|
1459 | Only the document based workbook may be used (see <a href="#create-a-workbook">Create a Worbook</a> for details).
|
1460 |
|
1461 | For example code using ExcelJS in the browser take a look at the <a href="https://github.com/guyonroche/exceljs/tree/master/spec/browser">spec/browser</a> folder in the github repo.
|
1462 |
|
1463 | ## Prebundled
|
1464 |
|
1465 | The following files are pre-bundled and included inside the dist folder.
|
1466 |
|
1467 | * exceljs.js
|
1468 | * exceljs.min.js
|
1469 |
|
1470 | # Value Types
|
1471 |
|
1472 | The following value types are supported.
|
1473 |
|
1474 | ## Null Value
|
1475 |
|
1476 | Enum: Excel.ValueType.Null
|
1477 |
|
1478 | A null value indicates an absence of value and will typically not be stored when written to file (except for merged cells).
|
1479 | It can be used to remove the value from a cell.
|
1480 |
|
1481 | E.g.
|
1482 |
|
1483 | ```javascript
|
1484 | worksheet.getCell('A1').value = null;
|
1485 | ```
|
1486 |
|
1487 | ## Merge Cell
|
1488 |
|
1489 | Enum: Excel.ValueType.Merge
|
1490 |
|
1491 | A merge cell is one that has its value bound to another 'master' cell.
|
1492 | Assigning to a merge cell will cause the master's cell to be modified.
|
1493 |
|
1494 | ## Number Value
|
1495 |
|
1496 | Enum: Excel.ValueType.Number
|
1497 |
|
1498 | A numeric value.
|
1499 |
|
1500 | E.g.
|
1501 |
|
1502 | ```javascript
|
1503 | worksheet.getCell('A1').value = 5;
|
1504 | worksheet.getCell('A2').value = 3.14159;
|
1505 | ```
|
1506 |
|
1507 | ## String Value
|
1508 |
|
1509 | Enum: Excel.ValueType.String
|
1510 |
|
1511 | A simple text string.
|
1512 |
|
1513 | E.g.
|
1514 |
|
1515 | ```javascript
|
1516 | worksheet.getCell('A1').value = 'Hello, World!';
|
1517 | ```
|
1518 |
|
1519 | ## Date Value
|
1520 |
|
1521 | Enum: Excel.ValueType.Date
|
1522 |
|
1523 | A date value, represented by the JavaScript Date type.
|
1524 |
|
1525 | E.g.
|
1526 |
|
1527 | ```javascript
|
1528 | worksheet.getCell('A1').value = new Date(2017, 2, 15);
|
1529 | ```
|
1530 |
|
1531 | ## Hyperlink Value
|
1532 |
|
1533 | Enum: Excel.ValueType.Hyperlink
|
1534 |
|
1535 | A URL with both text and link value.
|
1536 |
|
1537 | E.g.
|
1538 | ```javascript
|
1539 | // link to web
|
1540 | worksheet.getCell('A1').value = { text: 'www.mylink.com', hyperlink: 'http://www.mylink.com' };
|
1541 |
|
1542 | // internal link
|
1543 | worksheet.getCell('A1').value = { text: 'Sheet2', hyperlink: '#\\"Sheet2\\"!A1' };
|
1544 | ```
|
1545 |
|
1546 | ## Formula Value
|
1547 |
|
1548 | Enum: Excel.ValueType.Formula
|
1549 |
|
1550 | An Excel formula for calculating values on the fly.
|
1551 | Note that while the cell type will be Formula, the cell may have an effectiveType value that will
|
1552 | be derived from the result value.
|
1553 |
|
1554 | Note that ExcelJS cannot process the formula to generate a result, it must be supplied.
|
1555 |
|
1556 | E.g.
|
1557 |
|
1558 | ```javascript
|
1559 | worksheet.getCell('A3').value = { formula: 'A1+A2', result: 7 };
|
1560 | ```
|
1561 |
|
1562 | Cells also support convenience getters to access the formula and result:
|
1563 |
|
1564 | ```javascript
|
1565 | worksheet.getCell('A3').formula === 'A1+A2';
|
1566 | worksheet.getCell('A3').result === 7;
|
1567 | ```
|
1568 |
|
1569 | ### Shared Formula
|
1570 |
|
1571 | Shared formulae enhance the compression of the xlsx document by increasing the repetition
|
1572 | of text within the worksheet xml.
|
1573 |
|
1574 | A shared formula can be assigned to a cell using a new value form:
|
1575 |
|
1576 | ```javascript
|
1577 | worksheet.getCell('B3').value = { sharedFormula: 'A3', result: 10 };
|
1578 | ```
|
1579 |
|
1580 | This specifies that the cell B3 is a formula that will be derived from the formula in
|
1581 | A3 and its result is 10.
|
1582 |
|
1583 | The formula convenience getter will translate the formula in A3 to what it should be in B3:
|
1584 |
|
1585 | ```javascript
|
1586 | worksheet.getCell('B3').formula === 'B1+B2';
|
1587 | ```
|
1588 |
|
1589 | ### Formula Type
|
1590 |
|
1591 | To distinguish between real and translated formula cells, use the formulaType getter:
|
1592 |
|
1593 | ```javascript
|
1594 | worksheet.getCell('A3').formulaType === Enums.FormulaType.Master;
|
1595 | worksheet.getCell('B3').formulaType === Enums.FormulaType.Shared;
|
1596 | ```
|
1597 |
|
1598 | Formula type has the following values:
|
1599 |
|
1600 | | Name | Value |
|
1601 | | -------------------------- | ------- |
|
1602 | | Enums.FormulaType.None | 0 |
|
1603 | | Enums.FormulaType.Master | 1 |
|
1604 | | Enums.FormulaType.Shared | 2 |
|
1605 |
|
1606 | ## Rich Text Value
|
1607 |
|
1608 | Enum: Excel.ValueType.RichText
|
1609 |
|
1610 | Rich, styled text.
|
1611 |
|
1612 | E.g.
|
1613 | ```javascript
|
1614 | worksheet.getCell('A1').value = {
|
1615 | richText: [
|
1616 | { text: 'This is '},
|
1617 | {font: {italic: true}, text: 'italic'},
|
1618 | ]
|
1619 | };
|
1620 | ```
|
1621 |
|
1622 | ## Boolean Value
|
1623 |
|
1624 | Enum: Excel.ValueType.Boolean
|
1625 |
|
1626 | E.g.
|
1627 |
|
1628 | ```javascript
|
1629 | worksheet.getCell('A1').value = true;
|
1630 | worksheet.getCell('A2').value = false;
|
1631 | ```
|
1632 |
|
1633 | ## Error Value
|
1634 |
|
1635 | Enum: Excel.ValueType.Error
|
1636 |
|
1637 | E.g.
|
1638 |
|
1639 | ```javascript
|
1640 | worksheet.getCell('A1').value = { error: '#N/A' };
|
1641 | worksheet.getCell('A2').value = { error: '#VALUE!' };
|
1642 | ```
|
1643 |
|
1644 | The current valid Error text values are:
|
1645 |
|
1646 | | Name | Value |
|
1647 | | ------------------------------ | ----------- |
|
1648 | | Excel.ErrorValue.NotApplicable | #N/A |
|
1649 | | Excel.ErrorValue.Ref | #REF! |
|
1650 | | Excel.ErrorValue.Name | #NAME? |
|
1651 | | Excel.ErrorValue.DivZero | #DIV/0! |
|
1652 | | Excel.ErrorValue.Null | #NULL! |
|
1653 | | Excel.ErrorValue.Value | #VALUE! |
|
1654 | | Excel.ErrorValue.Num | #NUM! |
|
1655 |
|
1656 | # Interface Changes
|
1657 |
|
1658 | Every effort is made to make a good consistent interface that doesn't break through the versions but regrettably, now and then some things have to change for the greater good.
|
1659 |
|
1660 | ## 0.1.0
|
1661 |
|
1662 | ### Worksheet.eachRow
|
1663 |
|
1664 | The arguments in the callback function to Worksheet.eachRow have been swapped and changed; it was function(rowNumber,rowValues), now it is function(row, rowNumber) which gives it a look and feel more like the underscore (_.each) function and prioritises the row object over the row number.
|
1665 |
|
1666 | ### Worksheet.getRow
|
1667 |
|
1668 | This function has changed from returning a sparse array of cell values to returning a Row object. This enables accessing row properties and will facilitate managing row styles and so on.
|
1669 |
|
1670 | The sparse array of cell values is still available via Worksheet.getRow(rowNumber).values;
|
1671 |
|
1672 | ## 0.1.1
|
1673 |
|
1674 | ### cell.model
|
1675 |
|
1676 | cell.styles renamed to cell.style
|
1677 |
|
1678 | ## 0.2.44
|
1679 |
|
1680 | Promises returned from functions switched from Bluebird to native node Promise which can break calling code
|
1681 | if they rely on Bluebird's extra features.
|
1682 |
|
1683 | To mitigate this the following two changes were added to 0.3.0:
|
1684 |
|
1685 | * A more fully featured and still browser compatable promise lib is used by default. This lib supports many of the features of Bluebird but with a much lower footprint.
|
1686 | * An option to inject a different Promise implementation. See <a href="#config">Config</a> section for more details.
|
1687 |
|
1688 | # Config
|
1689 |
|
1690 | ExcelJS now supports dependency injection for the promise library.
|
1691 | You can restore Bluebird promises by including the following code in your module...
|
1692 |
|
1693 | ```javascript
|
1694 | ExcelJS.config.setValue('promise', require('bluebird'));
|
1695 | ```
|
1696 |
|
1697 | Please note: I have tested ExcelJS with bluebird specifically (since up until recently this was the library it used).
|
1698 | From the tests I have done it will not work with Q.
|
1699 |
|
1700 | # Known Issues
|
1701 |
|
1702 | ## Testing with PhantomJS
|
1703 |
|
1704 | You may need to install phantomjs globally before running the browser-test script.
|
1705 |
|
1706 | It's also possible that phantomjs will not run (or can't be found). If this happens, try the following:
|
1707 |
|
1708 | ```bash
|
1709 | sudo apt-get install libfontconfig
|
1710 | ```
|
1711 |
|
1712 | ## Splice vs Merge
|
1713 |
|
1714 | If any splice operation affects a merged cell, the merge group will not be moved correctly
|
1715 |
|
1716 | # Release History
|
1717 |
|
1718 | | Version | Changes |
|
1719 | | ------- | ------- |
|
1720 | | 0.0.9 | <ul><li><a href="#number-formats">Number Formats</a></li></ul> |
|
1721 | | 0.1.0 | <ul><li>Bug Fixes<ul><li>"<" and ">" text characters properly rendered in xlsx</li></ul></li><li><a href="#columns">Better Column control</a></li><li><a href="#rows">Better Row control</a></li></ul> |
|
1722 | | 0.1.1 | <ul><li>Bug Fixes<ul><li>More textual data written properly to xml (including text, hyperlinks, formula results and format codes)</li><li>Better date format code recognition</li></ul></li><li><a href="#fonts">Cell Font Style</a></li></ul> |
|
1723 | | 0.1.2 | <ul><li>Fixed potential race condition on zip write</li></ul> |
|
1724 | | 0.1.3 | <ul><li><a href="#alignment">Cell Alignment Style</a></li><li><a href="#rows">Row Height</a></li><li>Some Internal Restructuring</li></ul> |
|
1725 | | 0.1.5 | <ul><li>Bug Fixes<ul><li>Now handles 10 or more worksheets in one workbook</li><li>theme1.xml file properly added and referenced</li></ul></li><li><a href="#borders">Cell Borders</a></li></ul> |
|
1726 | | 0.1.6 | <ul><li>Bug Fixes<ul><li>More compatable theme1.xml included in XLSX file</li></ul></li><li><a href="#fills">Cell Fills</a></li></ul> |
|
1727 | | 0.1.8 | <ul><li>Bug Fixes<ul><li>More compatable theme1.xml included in XLSX file</li><li>Fixed filename case issue</li></ul></li><li><a href="#fills">Cell Fills</a></li></ul> |
|
1728 | | 0.1.9 | <ul><li>Bug Fixes<ul><li>Added docProps files to satisfy Mac Excel users</li><li>Fixed filename case issue</li><li>Fixed worksheet id issue</li></ul></li><li><a href="#set-workbook-properties">Core Workbook Properties</a></li></ul> |
|
1729 | | 0.1.10 | <ul><li>Bug Fixes<ul><li>Handles File Not Found error</li></ul></li><li><a href="#csv">CSV Files</a></li></ul> |
|
1730 | | 0.1.11 | <ul><li>Bug Fixes<ul><li>Fixed Vertical Middle Alignment Issue</li></ul></li><li><a href="#styles">Row and Column Styles</a></li><li><a href="#rows">Worksheet.eachRow supports options</a></li><li><a href="#rows">Row.eachCell supports options</a></li><li><a href="#columns">New function Column.eachCell</a></li></ul> |
|
1731 | | 0.2.0 | <ul><li><a href="#streaming-xlxs-writer">Streaming XLSX Writer</a><ul><li>At long last ExcelJS can support writing massive XLSX files in a scalable memory efficient manner. Performance has been optimised and even smaller spreadsheets can be faster to write than the document writer. Options have been added to control the use of shared strings and styles as these can both have a considerable effect on performance</li></ul></li><li><a href="#rows">Worksheet.lastRow</a><ul><li>Access the last editable row in a worksheet.</li></ul></li><li><a href="#rows">Row.commit()</a><ul><li>For streaming writers, this method commits the row (and any previous rows) to the stream. Committed rows will no longer be editable (and are typically deleted from the worksheet object). For Document type workbooks, this method has no effect.</li></ul></li></ul> |
|
1732 | | 0.2.2 | <ul><li><a href="https://pbs.twimg.com/profile_images/2933552754/fc8c70829ee964c5542ae16453503d37.jpeg">One Billion Cells</a><ul><li>Achievement Unlocked: A simple test using ExcelJS has created a spreadsheet with 1,000,000,000 cells. Made using random data with 100,000,000 rows of 10 cells per row. I cannot validate the file yet as Excel will not open it and I have yet to implement the streaming reader but I have every confidence that it is good since 1,000,000 rows loads ok.</li></ul></li></ul> |
|
1733 | | 0.2.3 | <ul><li>Bug Fixes<ul><li><a href="https://github.com/guyonroche/exceljs/issues/18">Merge Cell Styles</a><ul><li>Merged cells now persist (and parse) their styles.</li></ul></li></ul></li><li><a href="#streaming-xlxs-writer">Streaming XLSX Writer</a><ul><li>At long last ExcelJS can support writing massive XLSX files in a scalable memory efficient manner. Performance has been optimised and even smaller spreadsheets can be faster to write than the document writer. Options have been added to control the use of shared strings and styles as these can both have a considerable effect on performance</li></ul></li><li><a href="#rows">Worksheet.lastRow</a><ul><li>Access the last editable row in a worksheet.</li></ul></li><li><a href="#rows">Row.commit()</a><ul><li>For streaming writers, this method commits the row (and any previous rows) to the stream. Committed rows will no longer be editable (and are typically deleted from the worksheet object). For Document type workbooks, this method has no effect.</li></ul></li></ul> |
|
1734 | | 0.2.4 | <ul><li>Bug Fixes<ul><li><a href="https://github.com/guyonroche/exceljs/issues/27">Worksheets with Ampersand Names</a><ul><li>Worksheet names are now xml-encoded and should work with all xml compatable characters</li></ul></li></ul></li><li><a href="#rows">Row.hidden</a> & <a href="#columns">Column.hidden</a><ul><li>Rows and Columns now support the hidden attribute.</li></ul></li><li><a href="#worksheet">Worksheet.addRows</a><ul><li>New function to add an array of rows (either array or object form) to the end of a worksheet.</li></ul></li></ul> |
|
1735 | | 0.2.6 | <ul><li>Bug Fixes<ul><li><a href="https://github.com/guyonroche/exceljs/issues/87">invalid signature: 0x80014</a>: Thanks to <a href="https://github.com/hasanlussa">hasanlussa</a> for the PR</li></ul></li><li><a href="#defined-names">Defined Names</a><ul><li>Cells can now have assigned names which may then be used in formulas.</li></ul></li><li>Converted Bluebird.defer() to new Bluebird(function(resolve, reject){}). Thanks to user <a href="https://github.com/Nishchit14">Nishchit</a> for the Pull Request</li></ul> |
|
1736 | | 0.2.7 | <ul><li><a href="#data-validations">Data Validations</a><ul><li>Cells can now define validations that controls the valid values the cell can have</li></ul></li></ul> |
|
1737 | | 0.2.8 | <ul><li><a href="rich-text">Rich Text Value</a><ul><li>Cells now support <b><i>in-cell</i></b> formatting - Thanks to <a href="https://github.com/pvadam">Peter ADAM</a></li></ul></li><li>Fixed typo in README - Thanks to <a href="https://github.com/MRdNk">MRdNk</a></li><li>Fixing emit in worksheet-reader - Thanks to <a href="https://github.com/alangunning">Alan Gunning</a></li><li>Clearer Docs - Thanks to <a href="https://github.com/miensol">miensol</a></li></ul> |
|
1738 | | 0.2.9 | <ul><li>Fixed "read property 'richText' of undefined error. Thanks to <a href="https://github.com/james075">james075</a></li></ul> |
|
1739 | | 0.2.10 | <ul><li>Refactoring Complete. All unit and integration tests pass.</li></ul> |
|
1740 | | 0.2.11 | <ul><li><a href="#outline-level">Outline Levels</a>. Thanks to <a href="https://github.com/cricri">cricri</a> for the contribution.</li><li><a href="#worksheet-properties">Worksheet Properties</a></li><li>Further refactoring of worksheet writer.</li></ul> |
|
1741 | | 0.2.12 | <ul><li><a href="#worksheet-views">Sheet Views</a>. Thanks to <a href="https://github.com/cricri">cricri</a> again for the contribution.</li></ul> |
|
1742 | | 0.2.13 | <ul><li>Fix for <a href="https://github.com/guyonroche/exceljs/issues">exceljs might be vulnerable for regular expression denial of service</a>. Kudos to <a href="https://github.com/yonjah">yonjah</a> and <a href="https://www.youtube.com/watch?v=wCfE-9bhY2Y">Josh Emerson</a> for the resolution.</li><li>Fix for <a href="https://github.com/guyonroche/exceljs/issues/162">Multiple Sheets opens in 'Group' mode in Excel</a>. My bad - overzealous sheet view code.</li><li>Also fix for empty sheet generating invalid xlsx.</li></ul> |
|
1743 | | 0.2.14 | <ul><li>Fix for <a href="https://github.com/guyonroche/exceljs/issues">exceljs might be vulnerable for regular expression denial of service</a>. Kudos to <a href="https://github.com/yonjah">yonjah</a> and <a href="https://www.youtube.com/watch?v=wCfE-9bhY2Y">Josh Emerson</a> for the resolution.</li><li>Fixed <a href="https://github.com/guyonroche/exceljs/issues/162">Multiple Sheets opens in 'Group' mode in Excel</a> again. Added <a href="#workbook-views">Workbook views</a>.</li><li>Also fix for empty sheet generating invalid xlsx.</li></ul> |
|
1744 | | 0.2.15 | <ul><li>Added <a href="#page-setup">Page Setup Properties</a>. Thanks to <a href="https://github.com/jackkum">Jackkum</a> for the PR</li></ul> |
|
1745 | | 0.2.16 | <ul><li>New <a href="#page-setup">Page Setup</a> Property: Print Area</li></ul> |
|
1746 | | 0.2.17 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/114">Fix a bug on phonetic characters</a>. This fixes an issue related to reading workbooks with phonetic text in. Note phonetic text is not properly supported yet - just properly ignored. Thanks to <a href="https://github.com/zephyrrider">zephyrrider</a> and <a href="https://github.com/gen6033">gen6033</a> for the contribution.</li></ul> |
|
1747 | | 0.2.18 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/175">Fix regression #150: Stream API fails to write XLSX files</a>. Apologies for the regression! Thanks to <a href="https://github.com/danieleds">danieleds</a> for the fix.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/114">Fix a bug on phonetic characters</a>. This fixes an issue related to reading workbooks with phonetic text in. Note phonetic text is not properly supported yet - just properly ignored. Thanks to <a href="https://github.com/zephyrrider">zephyrrider</a> and <a href="https://github.com/gen6033">gen6033</a> for the contribution.</li></ul> |
|
1748 | | 0.2.19 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/119">Update xlsx.js #119</a>. This should make parsing more resilient to open-office documents. Thanks to <a href="https://github.com/nvitaterna">nvitaterna</a> for the contribution.</li></ul> |
|
1749 | | 0.2.20 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/179">Changes from guyonroche/exceljs#127 applied to latest version #179</a>. Fixes parsing of defined name values. Thanks to <a href="https://github.com/agdevbridge">agdevbridge</a> and <a href="https://github.com/priitliivak">priitliivak</a> for the contribution.</li></ul> |
|
1750 | | 0.2.21 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/135">color tabs for worksheet-writer #135</a>. Modified the behaviour to print deprecation warning as tabColor has moved into options.properties. Thanks to <a href="https://github.com/ethanlook">ethanlook</a> for the contribution.</li></ul> |
|
1751 | | 0.2.22 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/136">Throw legible error when failing Value.getType() #136</a>. Thanks to <a href="https://github.com/wulfsolter">wulfsolter</a> for the contribution.</li><li>Honourable mention to contributors whose PRs were fixed before I saw them:<ul><li><a href="https://github.com/haoliangyu">haoliangyu</a></li><li><a href="https://github.com/wulfsolter">wulfsolter</a></li></ul></li></ul> |
|
1752 | | 0.2.23 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/137">Fall back to JSON.stringify() if unknown Cell.Type #137</a> with some modification. If a cell value is assigned to an unrecognisable javascript object, the stored value in xlsx and csv files will be JSON stringified. Note that if the file is read again, no attempt will be made to parse the stringified JSON text. Thanks to <a href="https://github.com/wulfsolter">wulfsolter</a> for the contribution.</li></ul> |
|
1753 | | 0.2.24 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/166">Protect cell fix #166</a>. This does not mean full support for protected cells merely that the parser is not confused by the extra xml. Thanks to <a href="https://github.com/jayflo">jayflo</a> for the contribution.</li></ul> |
|
1754 | | 0.2.25 | <ul><li>Added functions to delete cells, rows and columns from a worksheet. Modelled after the Array splice method, the functions allow cells, rows and columns to be deleted (and optionally inserted). See <a href="#columns">Columns</a> and <a href="#rows">Rows</a> for details.<br />Note: <a href="#splice-vs-merge">Not compatable with cell merges</a></li></ul> |
|
1755 | | 0.2.26 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/184">Update border-xform.js #184</a>Border edges without style will be parsed and rendered as no-border. Thanks to <a href="https://github.com/skumarnk2">skumarnk2</a> for the contribution.</li></ul> |
|
1756 | | 0.2.27 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/187">Pass views to worksheet-writer #187</a>. Now also passes views to worksheet-writer. Thanks to <a href="https://github.com/Temetz">Temetz</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/189">Do not escape xml characters when using shared strings #189</a>. Fixing bug in shared strings. Thanks to <a href="https://github.com/tkirda">tkirda</a> for the contribution.</li></ul> |
|
1757 | | 0.2.28 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/190">Fix tiny bug [Update hyperlink-map.js] #190</a>Thanks to <a href="https://github.com/lszlkss">lszlkss</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/196">fix typo on sheet view showGridLines option #196</a> "showGridlines" should have been "showGridLines". Thanks to <a href="https://github.com/gadiaz1">gadiaz1</a> for the contribution.</li></ul> |
|
1758 | | 0.2.29 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/199">Fire finish event instead of end event on write stream #199</a> and <a href="https://github.com/guyonroche/exceljs/pull/200">Listen for finish event on zip stream instead of middle stream #200</a>. Fixes issues with stream completion events. Thanks to <a href="https://github.com/junajan">junajan</a> for the contribution.</li></ul> |
|
1759 | | 0.2.30 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/201">Fix issue #178 #201</a>. Adds the following properties to workbook:<ul><li>title</li><li>subject</li><li>keywords</li><li>category</li><li>description</li><li>company</li><li>manager</li></ul>Thanks to <a href="https://github.com/stavenko">stavenko</a> for the contribution.</li></ul> |
|
1760 | | 0.2.31 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/203">Fix issue #163: the "spans" attribute of the row element is optional #203</a>. Now xlsx parsing will handle documents without row spans. Thanks to <a href="https://github.com/arturas-vitkauskas">arturas-vitkauskas</a> for the contribution.</li></ul> |
|
1761 | | 0.2.32 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/208">Fix issue 206 #208</a>. Fixes issue reading xlsx files that have been printed. Also adds "lastPrinted" property to Workbook. Thanks to <a href="https://github.com/arturas-vitkauskas">arturas-vitkauskas</a> for the contribution.</li></ul> |
|
1762 | | 0.2.33 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/210">Allow styling of cells with no value. #210</a>. Includes Null type cells with style in the rendering parsing. Thanks to <a href="https://github.com/oferns">oferns</a> for the contribution.</li></ul> |
|
1763 | | 0.2.34 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/212">Fix "Unexpected xml node in parseOpen" bug in LibreOffice documents for attributes dc:language and cp:revision #212</a>. Thanks to <a href="https://github.com/jessica-jordan">jessica-jordan</a> for the contribution.</li></ul> |
|
1764 | | 0.2.35 | <ul><li>Fixed <a href="https://github.com/guyonroche/exceljs/issues/74">Getting a column/row count #74</a>. <a href="#worksheet-metrics">Worksheet</a> now has rowCount and columnCount properties (and actual variants), <a href="row">Row</a> has cellCount.</li></ul> |
|
1765 | | 0.2.36 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/217">Stream reader fixes #217</a>. Thanks to <a href="https://github.com/kturney">kturney</a> for the contribution.</li></ul> |
|
1766 | | 0.2.37 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/225">Fix output order of Sheet Properties #225</a>. Thanks to <a href="https://github.com/keeneym">keeneym</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/231">remove empty worksheet[0] from _worksheets #231</a>. Thanks to <a href="https://github.com/pookong">pookong</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/232">do not skip empty string in shared strings so that indexes match #232</a>. Thanks again to <a href="https://github.com/pookong">pookong</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/233">use shared strings for streamed writes #233</a>. Thanks again to <a href="https://github.com/pookong">pookong</a> for the contribution.</li></ul> |
|
1767 | | 0.2.38 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/236">Add a comment for issue #216 #236</a>. Thanks to <a href="https://github.com/jsalwen">jsalwen</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/237">Start on support for 1904 based dates #237</a>. Fixed date handling in documents with the 1904 flag set. Thanks to <a href="https://github.com/holm">holm</a> for the contribution.</li></ul> |
|
1768 | | 0.2.39 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/245">Stops Bluebird warning about unreturned promise #245</a>. Thanks to <a href="https://github.com/robinbullocks4rb">robinbullocks4rb</a> for the contribution. </li> <li> Merged <a href="https://github.com/guyonroche/exceljs/pull/247">Added missing dependency: col-cache.js #247</a>. Thanks to <a href="https://github.com/Manish2005">Manish2005</a> for the contribution. </li> </ul> |
|
1769 | | 0.2.42 | <ul><li>Browser Compatable!<ul><li>Well mostly. I have added a browser sub-folder that contains a browserified bundle and an index.js that can be used to generate another. See <a href="#browser">Browser</a> section for details.</li></ul></li><li>Fixed corrupted theme.xml. Apologies for letting that through.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/253">[BUGFIX] data validation formulae undefined #253</a>. Thanks to <a href="https://github.com/jayflo">jayflo</a> for the contribution.</li></ul> |
|
1770 | | 0.2.43 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/255">added a (maybe partial) solution to issue 99. i wasn't able to create an appropriate test #255</a>. This fixes <a href="https://github.com/guyonroche/exceljs/issues/99">Too few data or empty worksheet generate malformed excel file #99</a>. Thanks to <a href="https://github.com/mminuti">mminuti</a> for the contribution.</li></ul> |
|
1771 | | 0.2.44 | <ul><li>Reduced Dependencies.<ul><li>Goodbye lodash, goodbye bluebird. Minified bundle is now just over half what it was in the first version.</li></ul></li></ul> |
|
1772 | | 0.2.45 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/256">Sheets with hyperlinks and data validations are corrupted #256</a>. Thanks to <a href="https://github.com/simon-stoic">simon-stoic</a> for the contribution.</li></ul> |
|
1773 | | 0.2.46 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/259">Exclude character controls from XML output. Fixes #234 #262</a>. Thanks to <a href="https://github.com/holm">holm</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/262">Add support for identifier #259</a>. This fixes <a href="https://github.com/guyonroche/exceljs/issues/234">Broken XLSX because of "vertical tab" ascii character in a cell #234</a>. Thanks to <a href="https://github.com/NOtherDev">NOtherDev</a> for the contribution.</li></ul> |
|
1774 | | 0.3.0 | <ul><li>Addressed <a href="https://github.com/guyonroche/exceljs/issues/266">Breaking change removing bluebird #266</a>. Appologies for any inconvenience.</li><li>Added Promise library dependency injection. See <a href="#config">Config</a> section for more details.</li></ul> |
|
1775 | | 0.3.1 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/279">Update dependencies #279</a>. Thanks to <a href="https://github.com/holm">holm</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/267">Minor fixes for stream handling #267</a>. Thanks to <a href="https://github.com/holm">holm</a> for the contribution.</li><li>Added automated tests in phantomjs for the browserified code.</li></ul> |
|
1776 | | 0.4.0 | <ul><li>Fixed issue <a href="https://github.com/guyonroche/exceljs/issues/278">Boolean cell with value ="true" is returned as 1 #278</a>. The fix involved adding two new Call Value types:<ul><li><a href="#boolean-value">Boolean Value</a></li><li><a href="#error-value">Error Value</a></li></ul>Note: Minor version has been bumped up to 4 as this release introduces a couple of interface changes:<ul><li>Boolean cells previously will have returned 1 or 0 will now return true or false</li><li>Error cells that previously returned a string value will now return an error structure</li></ul></li><li>Fixed issue <a href="https://github.com/guyonroche/exceljs/issues/280">Code correctness - setters don't return a value #280</a>.</li><li>Addressed issue <a href="https://github.com/guyonroche/exceljs/issues/288">v0.3.1 breaks meteor build #288</a>.</li></ul> |
|
1777 | | 0.4.1 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/285">Add support for cp:contentStatus #285</a>. Thanks to <a href="https://github.com/holm">holm</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/286">Fix Valid characters in XML (allow \n and \r when saving) #286</a>. Thanks to <a href="https://github.com/Rycochet">Rycochet</a> for the contribution.</li><li>Fixed <a href="https://github.com/guyonroche/exceljs/issues/275">hyperlink with query arguments corrupts workbook #275</a>. The hyperlink target is not escaped before serialising in the xml.</li></ul> |
|
1778 | | 0.4.2 | <ul><li><p>Addressed the following issues:<ul><li><a href="https://github.com/guyonroche/exceljs/issues/290">White text and borders being changed to black #290</a></li><li><a href="https://github.com/guyonroche/exceljs/issues/261">Losing formatting/pivot table from loaded file #261</a></li><li><a href="https://github.com/guyonroche/exceljs/issues/272">Solid fill become black #272</a></li></ul>These issues are potentially caused by a bug that caused colours with zero themes, tints or indexes to be rendered and parsed incorrectly.</p><p>Regarding themes: the theme files stored inside the xlsx container hold important information regarding colours, styles etc and if the theme information from a loaded xlsx file is lost, the results can be unpredictable and undesirable. To address this, when an ExcelJS Workbook parses an XLSX file, it will preserve any theme files it finds and include them when writing to a new XLSX. If this behaviour is not desired, the Workbook class exposes a clearThemes() function which will drop the theme content. Note that this behaviour is only implemented in the document based Workbook class, not the streamed Reader and Writer.</p></li></ul> |
|
1779 | | 0.4.3 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/294">Support error references in cell ranges #294</a>. Thanks to <a href="https://github.com/holm">holm</a> for the contribution.</li></ul> |
|
1780 | | 0.4.4 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/297">Issue with copied cells #297</a>. This merge adds support for shared formulas. Thanks to <a href="https://github.com/muscapades">muscapades</a> for the contribution.</li></ul> |
|
1781 | | 0.4.6 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/304">Correct spelling #304</a>. Thanks to <a href="https://github.com/toanalien">toanalien</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/304">Added support for auto filters #306</a>. This adds <a href="#auto-filters">Auto Filters</a> to the Worksheet. Thanks to <a href="https://github.com/C4rmond4i">C4rmond4i</a> for the contribution.</li><li>Restored NodeJS 4.0.0 compatability by removing the destructuring code. My apologies for any inconvenience.</li></ul> |
|
1782 | | 0.4.9 | <ul><li>Switching to transpiled code for distribution. This will ensure compatability with 4.0.0 and above from here on. And it will also allow use of much more expressive JS code in the lib folder!</li><li><a href="#images">Basic Image Support!</a>Images can now be added to worksheets either as a tiled background or stretched over a range. Note: other features like rotation, etc. are not supported yet and will reqeuire further work.</li></ul> |
|
1783 | | 0.4.10 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/319">Add missing Office Rels #319</a>. Thanks goes to <a href="https://github.com/mauriciovillalobos">mauriciovillalobos</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/320">Add printTitlesRow Support #320</a> Thanks goes to <a href="https://github.com/psellers89">psellers89</a> for the contribution.</li></ul> |
|
1784 | | 0.4.11 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/327">Avoid error on anchor with no media #327</a>. Thanks goes to <a href="https://github.com/holm">holm</a> for the contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/332">Assortment of fixes for streaming read #332</a>. Thanks goes to <a href="https://github.com/holm">holm</a> for the contribution.</li></ul> |
|
1785 | | 0.4.12 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/334">Don’t set address if hyperlink r:id is undefined #334</a>. Thanks goes to <a href="https://github.com/holm">holm</a> for the contribution.</li></ul> |
|
1786 | | 0.4.13 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/343">Issue 296 #343</a>. This fixes <a href="https://github.com/guyonroche/exceljs/issues/296">Issue with writing newlines #296</a>. Thanks goes to <a href="https://github.com/holly-weisser">holly-weisser</a> for the contribution.</li></ul> |
|
1787 | | 0.4.14 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/350">Syntax highlighting added ✨ #350</a>. Thanks goes to <a href="https://github.com/rmariuzzo">rmariuzzo</a> for the contribution.</li></ul> |
|
1788 | | 0.5.0 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/356">Fix right to left issues #356</a>. Fixes <a href="https://github.com/guyonroche/exceljs/issues/72">Add option to RTL file #72</a> and <a href="https://github.com/guyonroche/exceljs/issues/126">Adding an option to set RTL worksheet #126</a>. Big thank you to <a href="https://github.com/alitaheri">alitaheri</a> for this contribution.</li></ul> |
|
1789 | | 0.5.1 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/364">Fix #345 TypeError: Cannot read property 'date1904' of undefined #364</a>. This fixes <a href="https://github.com/guyonroche/exceljs/issues/345">TypeError: Cannot read property 'date1904' of undefined #345</a>. Thanks to <a href="https://github.com/Diluka">Diluka</a> for this contribution.</li></ul>
|
1790 | | 0.6.0 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/389">Add rowBreaks feature. #389</a>. Thanks to <a href="https://github.com/brucejo75">brucejo75</a> for this contribution.</li></ul> |
|
1791 | | 0.6.1 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/403">Guard null model fields - fix and tests #403</a>. Thanks to <a href="https://github.com/shdd-cjharries">thecjharries</a> for this contribution. Also thanks to <a href="https://github.com/Rycochet">Ryc O'Chet</a> for help with reviewing.</li></ul> |
|
1792 | | 0.6.2 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/396">Add some comments in readme according csv importing #396</a>. Thanks to <a href="https://github.com/Imperat">Michael Lelyakin</a> for this contribution. Also thanks to <a href="https://github.com/planemar">planemar</a> for help with reviewing. This also closes <a href="https://github.com/guyonroche/exceljs/issues/395">csv to stream doesn't work #395</a>.</li></ul> |
|
1793 | | 0.7.0 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/407">Impl <xdr:twoCellAnchor editAs=oneCell> #407</a>. Thanks to <a href="https://github.com/Ockejanssen">Ocke Janssen</a> and <a href="https://github.com/kay-ramme">Kay Ramme</a> for this contribution. This change allows control on how images are anchored to cells.</li></ul> |
|
1794 | | 0.7.1 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/423">Don't break when attempting to import a zip file that's not an Excel file (eg. .numbers) #423</a>. Thanks to <a href="https://github.com/papandreou">Andreas Lind</a> for this contribution. This change makes exceljs more reslilient when opening non-excel files.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/434">Fixes #419 : Updates readme. #434</a>. Thanks to <a href="https://github.com/getsomecoke">Vishnu Kyatannawar</a> for this contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/436">Don't break when docProps/core.xml contains a <cp:version> tag #436</a>. Thanks to <a href="https://github.com/papandreou">Andreas Lind</a> for this contribution. This change handles core.xml files with empty version tags.</li></ul>
|
1795 | | 0.8.0 | <ul><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/442">Add Base64 Image support for the .addImage() method #442</a>. Thanks to <a href="https://github.com/jwmann">James W Mann</a> for this contribution.</li><li>Merged <a href="https://github.com/guyonroche/exceljs/pull/453">update moment to 2.19.3 #453</a>. Thanks to <a href="https://github.com/cooltoast">Markan Patel</a> for this contribution.</li></ul> |
|
1796 | | 0.8.1 | <ul><li> Merged <a href="https://github.com/guyonroche/exceljs/pull/457">Additional information about font family property #457</a>. Thanks to <a href="https://github.com/kayakyakr">kayakyakr</a> for this contribution. </li> <li> Merged <a href="https://github.com/guyonroche/exceljs/pull/459">Fixes #458 #459</a>. This fixes <a href="https://github.com/guyonroche/exceljs/issues/458">Add style to column causes it to be hidden #458</a>. Thanks to <a href="https://github.com/AJamesPhillips">Alexander James Phillips</a> for this contribution. </li> </ul> |
|
1797 |
|