| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | ## Writing Options
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The exported `write` and `writeFile` functions accept an options argument: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | Option Name |  Default | Description                                         | | 
					
						
							|  |  |  | | :---------- | -------: | :-------------------------------------------------- | | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | |`type`       |          | Output data encoding (see Output Type below)        | | 
					
						
							|  |  |  | |`cellDates`  |  `false` | Store dates as type `d` (default is `n`)            | | 
					
						
							|  |  |  | |`bookSST`    |  `false` | Generate Shared String Table **                     | | 
					
						
							|  |  |  | |`bookType`   | `"xlsx"` | Type of Workbook (see below for supported formats)  | | 
					
						
							|  |  |  | |`sheet`      |     `""` | Name of Worksheet for single-sheet formats **       | | 
					
						
							|  |  |  | |`compression`|  `false` | Use ZIP compression for ZIP-based formats **        | | 
					
						
							|  |  |  | |`Props`      |          | Override workbook properties when writing **        | | 
					
						
							|  |  |  | |`themeXLSX`  |          | Override theme XML when writing XLSX/XLSB/XLSM **   | | 
					
						
							| 
									
										
										
										
											2018-08-15 19:22:47 +00:00
										 |  |  | |`ignoreEC`   |   `true` | Suppress "number as text" errors **                 | | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | - `bookSST` is slower and more memory intensive, but has better compatibility | 
					
						
							|  |  |  |   with older versions of iOS Numbers | 
					
						
							| 
									
										
										
										
											2017-03-27 21:35:15 +00:00
										 |  |  | - The raw data is the only thing guaranteed to be saved.  Features not described | 
					
						
							|  |  |  |   in this README may not be serialized. | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | - `cellDates` only applies to XLSX output and is not guaranteed to work with | 
					
						
							|  |  |  |   third-party readers.  Excel itself does not usually write cells with type `d` | 
					
						
							| 
									
										
										
										
											2017-08-01 05:50:53 +00:00
										 |  |  |   so non-Excel tools may ignore the data or error in the presence of dates. | 
					
						
							| 
									
										
										
										
											2017-04-10 05:10:54 +00:00
										 |  |  | - `Props` is an object mirroring the workbook `Props` field.  See the table from | 
					
						
							|  |  |  |   the [Workbook File Properties](#workbook-file-properties) section. | 
					
						
							| 
									
										
										
										
											2017-04-17 02:08:23 +00:00
										 |  |  | - if specified, the string from `themeXLSX` will be saved as the primary theme | 
					
						
							|  |  |  |   for XLSX/XLSB/XLSM files (to `xl/theme/theme1.xml` in the ZIP) | 
					
						
							| 
									
										
										
										
											2018-08-15 19:22:47 +00:00
										 |  |  | - Due to a bug in the program, some features like "Text to Columns" will crash | 
					
						
							|  |  |  |   Excel on worksheets where error conditions are ignored.  The writer will mark | 
					
						
							|  |  |  |   files to ignore the error by default.  Set `ignoreEC` to `false` to suppress. | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Supported Output Formats
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For broad compatibility with third-party tools, this library supports many | 
					
						
							|  |  |  | output formats.  The specific file type is controlled with `bookType` option: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | | `bookType` | file ext | container | sheets | Description                     | | 
					
						
							|  |  |  | | :--------- | -------: | :-------: | :----- |:------------------------------- | | 
					
						
							|  |  |  | | `xlsx`     | `.xlsx`  |    ZIP    | multi  | Excel 2007+ XML Format          | | 
					
						
							|  |  |  | | `xlsm`     | `.xlsm`  |    ZIP    | multi  | Excel 2007+ Macro XML Format    | | 
					
						
							|  |  |  | | `xlsb`     | `.xlsb`  |    ZIP    | multi  | Excel 2007+ Binary Format       | | 
					
						
							|  |  |  | | `biff8`    | `.xls`   |    CFB    | multi  | Excel 97-2004 Workbook Format   | | 
					
						
							| 
									
										
										
										
											2017-10-17 00:14:32 +00:00
										 |  |  | | `biff5`    | `.xls`   |    CFB    | multi  | Excel 5.0/95 Workbook Format    | | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | | `biff2`    | `.xls`   |   none    | single | Excel 2.0 Worksheet Format      | | 
					
						
							|  |  |  | | `xlml`     | `.xls`   |   none    | multi  | Excel 2003-2004 (SpreadsheetML) | | 
					
						
							|  |  |  | | `ods`      | `.ods`   |    ZIP    | multi  | OpenDocument Spreadsheet        | | 
					
						
							|  |  |  | | `fods`     | `.fods`  |   none    | multi  | Flat OpenDocument Spreadsheet   | | 
					
						
							|  |  |  | | `csv`      | `.csv`   |   none    | single | Comma Separated Values          | | 
					
						
							|  |  |  | | `txt`      | `.txt`   |   none    | single | UTF-16 Unicode Text (TXT)       | | 
					
						
							|  |  |  | | `sylk`     | `.sylk`  |   none    | single | Symbolic Link (SYLK)            | | 
					
						
							|  |  |  | | `html`     | `.html`  |   none    | single | HTML Document                   | | 
					
						
							|  |  |  | | `dif`      | `.dif`   |   none    | single | Data Interchange Format (DIF)   | | 
					
						
							| 
									
										
										
										
											2017-10-27 16:25:54 +00:00
										 |  |  | | `dbf`      | `.dbf`   |   none    | single | dBASE II + VFP Extensions (DBF) | | 
					
						
							| 
									
										
										
										
											2017-10-17 00:14:32 +00:00
										 |  |  | | `rtf`      | `.rtf`   |   none    | single | Rich Text Format (RTF)          | | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | | `prn`      | `.prn`   |   none    | single | Lotus Formatted Text            | | 
					
						
							| 
									
										
										
										
											2017-12-04 04:41:41 +00:00
										 |  |  | | `eth`      | `.eth`   |   none    | single | Ethercalc Record Format (ETH)   | | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | - `compression` only applies to formats with ZIP containers. | 
					
						
							|  |  |  | - Formats that only support a single sheet require a `sheet` option specifying | 
					
						
							|  |  |  |   the worksheet.  If the string is empty, the first worksheet is used. | 
					
						
							| 
									
										
										
										
											2017-04-03 00:16:03 +00:00
										 |  |  | - `writeFile` will automatically guess the output file format based on the file | 
					
						
							|  |  |  |   extension if `bookType` is not specified.  It will choose the first format in | 
					
						
							|  |  |  |   the aforementioned table that matches the extension. | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Output Type
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The `type` argument for `write` mirrors the `type` argument for `read`: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | `type`     | output                                                          | | 
					
						
							|  |  |  | |------------|-----------------------------------------------------------------| | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | | `"base64"` | string: Base64 encoding of the file                             | | 
					
						
							|  |  |  | | `"binary"` | string: binary string (byte `n` is `data.charCodeAt(n)`)        | | 
					
						
							| 
									
										
										
										
											2017-09-30 06:18:11 +00:00
										 |  |  | | `"string"` | string: JS string (characters interpreted as UTF8)              | | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | | `"buffer"` | nodejs Buffer                                                   | | 
					
						
							| 
									
										
										
										
											2017-12-30 05:40:35 +00:00
										 |  |  | | `"array"`  | ArrayBuffer, fallback array of 8-bit unsigned int               | | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | | `"file"`   | string: path of file that will be created (nodejs only)         | | 
					
						
							| 
									
										
										
										
											2017-03-20 09:02:25 +00:00
										 |  |  | 
 |