| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | #!/usr/bin/env jjs
 | 
					
						
							| 
									
										
										
										
											2017-09-05 05:26:50 +00:00
										 |  |  | /* xlsx.js (C) 2013-present  SheetJS -- http://sheetjs.com */ | 
					
						
							| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:06:35 +00:00
										 |  |  | /* load module */ | 
					
						
							|  |  |  | var global = (function(){ return this; }).call(null); | 
					
						
							|  |  |  | load('xlsx.full.min.js'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* helper to convert byte array to plain JS array */ | 
					
						
							| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | function b2a(b) { | 
					
						
							|  |  |  | 	var out = new Array(b.length); | 
					
						
							| 
									
										
										
										
											2018-02-14 20:06:35 +00:00
										 |  |  | 	for(var i = 0; i < out.length; i++) out[i] = (b[i] < 0 ? b[i] + 256 : b[i]); | 
					
						
							| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | 	return out; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:06:35 +00:00
										 |  |  | function process_file(path) { | 
					
						
							|  |  |  | 	java.lang.System.out.println(path); | 
					
						
							| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:06:35 +00:00
										 |  |  | 	/* read file */ | 
					
						
							|  |  |  | 	var path = java.nio.file.Paths.get(path); | 
					
						
							|  |  |  | 	var bytes = java.nio.file.Files.readAllBytes(path); | 
					
						
							|  |  |  | 	var u8a = b2a(bytes); | 
					
						
							| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:06:35 +00:00
										 |  |  | 	/* read data */ | 
					
						
							|  |  |  | 	var wb = XLSX.read(u8a, {type:"array"}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* get first worksheet as an array of arrays */ | 
					
						
							|  |  |  | 	var ws = wb.Sheets[wb.SheetNames[0]]; | 
					
						
							|  |  |  | 	var js = XLSX.utils.sheet_to_json(ws, {header:1}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* print out every line */ | 
					
						
							|  |  |  | 	js.forEach(function(l) { java.lang.System.out.println(JSON.stringify(l)); }); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-08-10 23:46:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 20:06:35 +00:00
										 |  |  | process_file('sheetjs.xlsx'); | 
					
						
							|  |  |  | process_file('sheetjs.xlsb'); | 
					
						
							|  |  |  | process_file('sheetjs.biff8.xls'); |