| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | # Adobe ExtendScript
 | 
					
						
							| 
									
										
										
										
											2017-03-25 22:18:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | ExtendScript adds some features to a limited form of ECMAScript version 3.  With | 
					
						
							|  |  |  | the included shim, the library can run within Photoshop and other Adobe apps! | 
					
						
							| 
									
										
										
										
											2017-03-25 22:18:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | The main file is `test.jsx`.  Target-specific files prepend target directives. | 
					
						
							| 
									
										
										
										
											2017-05-13 18:21:22 +00:00
										 |  |  | Copy the `test.jsx` file as well as the `shim.js` and `xlsx.core.min.js` files | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | to wherever you want the scripts to reside. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The demo shows opening a file and converting to an array of arrays: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | /* include library */ | 
					
						
							|  |  |  | #include "shim.js"
 | 
					
						
							|  |  |  | #include "xlsx.core.min.js"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* get data as binary string */ | 
					
						
							|  |  |  | var filename = "sheetjs.xlsx"; | 
					
						
							|  |  |  | var base = new File($.fileName); | 
					
						
							|  |  |  | var infile = File(base.path + "/" + filename); | 
					
						
							|  |  |  | infile.open("r"); | 
					
						
							|  |  |  | infile.encoding = "binary"; | 
					
						
							|  |  |  | var data = infile.read(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* parse data */ | 
					
						
							|  |  |  | var workbook = XLSX.read(data, {type:"binary"}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* DO SOMETHING WITH workbook HERE */ | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2017-05-13 18:21:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | NOTE: [We forked the minifier](https://www.npmjs.com/package/@sheetjs/uglify-js) | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | and included a patch for ExtendScript's switch statement semicolon issue. | 
					
						
							| 
									
										
										
										
											2017-05-13 18:21:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | [](https://github.com/SheetJS/js-xlsx) |