| 
									
										
										
										
											2017-04-16 04:32:13 +00:00
										 |  |  | ### Streaming Write
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 07:31:21 +00:00
										 |  |  | The streaming write functions are available in the `XLSX.stream` object.  They | 
					
						
							| 
									
										
										
										
											2017-06-10 01:47:42 +00:00
										 |  |  | take the same arguments as the normal write functions but return a Readable | 
					
						
							|  |  |  | Stream.  They are only exposed in NodeJS. | 
					
						
							| 
									
										
										
										
											2017-04-16 04:32:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 07:31:21 +00:00
										 |  |  | - `XLSX.stream.to_csv` is the streaming version of `XLSX.utils.sheet_to_csv`. | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | - `XLSX.stream.to_html` is the streaming version of `XLSX.utils.sheet_to_html`. | 
					
						
							| 
									
										
										
										
											2018-07-09 03:46:11 +00:00
										 |  |  | - `XLSX.stream.to_json` is the streaming version of `XLSX.utils.sheet_to_json`. | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | <details> | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  |   <summary><b>nodejs convert to CSV and write file</b> (click to show)</summary> | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | var output_file_name = "out.csv"; | 
					
						
							|  |  |  | var stream = XLSX.stream.to_csv(worksheet); | 
					
						
							|  |  |  | stream.pipe(fs.createWriteStream(output_file_name)); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </details> | 
					
						
							| 
									
										
										
										
											2017-04-16 07:31:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-09 03:46:11 +00:00
										 |  |  | <details> | 
					
						
							|  |  |  |   <summary><b>nodejs write JSON stream to screen</b> (click to show)</summary> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | /* to_json returns an object-mode stream */ | 
					
						
							|  |  |  | var stream = XLSX.stream.to_json(worksheet, {raw:true}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* the following stream converts JS objects to text via JSON.stringify */ | 
					
						
							|  |  |  | var conv = new Transform({writableObjectMode:true}); | 
					
						
							|  |  |  | conv._transform = function(obj, e, cb){ cb(null, JSON.stringify(obj) + "\n"); }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | stream.pipe(conv); conv.pipe(process.stdout); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </details> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-16 07:31:21 +00:00
										 |  |  | <https://github.com/sheetjs/sheetaki> pipes write streams to nodejs response. | 
					
						
							| 
									
										
										
										
											2017-04-30 20:37:53 +00:00
										 |  |  | 
 |