| 
									
										
										
										
											2024-06-15 06:47:40 +00:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | # https://docs.sheetjs.com/docs/demos/engines/jurassic | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cd /tmp | 
					
						
							|  |  |  | rm -rf SheetJSJurassic | 
					
						
							|  |  |  | mkdir SheetJSJurassic | 
					
						
							|  |  |  | cd SheetJSJurassic | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | dotnet new console | 
					
						
							|  |  |  | dotnet run | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-04 03:55:16 +00:00
										 |  |  | dotnet add package Jurassic --version 3.2.9 | 
					
						
							| 
									
										
										
										
											2024-06-15 06:47:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-18 22:19:02 +00:00
										 |  |  | curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js | 
					
						
							|  |  |  | curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.mini.min.js | 
					
						
							| 
									
										
										
										
											2024-06-15 06:47:40 +00:00
										 |  |  | curl -LO https://docs.sheetjs.com/pres.xlsx | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cat >Program.cs <<EOF | 
					
						
							|  |  |  | /* sheetjs (C) 2013-present  SheetJS -- https://sheetjs.com */ | 
					
						
							|  |  |  | /* vim: set ts=2: */ | 
					
						
							|  |  |  | var engine = new Jurassic.ScriptEngine(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Initialize Jurassic */ | 
					
						
							|  |  |  | engine.Evaluate("var global = (function(){ return this; }).call(null);"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Load SheetJS Scripts */ | 
					
						
							|  |  |  | engine.ExecuteFile("shim.min.js"); | 
					
						
							|  |  |  | engine.ExecuteFile("xlsx.mini.min.js"); | 
					
						
							|  |  |  | Console.WriteLine("SheetJS version {0}", engine.Evaluate("XLSX.version")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Read and Parse File */ | 
					
						
							|  |  |  | byte[] filedata = File.ReadAllBytes(args[0]); | 
					
						
							|  |  |  | string b64 = System.Convert.ToBase64String(filedata); | 
					
						
							|  |  |  | engine.SetGlobalValue("buf", b64); | 
					
						
							|  |  |  | engine.Evaluate("var wb = XLSX.read(buf, {type:'base64'});"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Print CSV of first worksheet*/ | 
					
						
							|  |  |  | engine.Evaluate("var ws = wb.Sheets[wb.SheetNames[0]];"); | 
					
						
							|  |  |  | object csv = engine.Evaluate("XLSX.utils.sheet_to_csv(ws)"); | 
					
						
							|  |  |  | Console.Write(csv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Generate XLSB file and save to SheetJSJurassic.ods */ | 
					
						
							|  |  |  | string ods = engine.Evaluate("XLSX.write(wb, {bookType: 'ods', type: 'base64'})") as string; | 
					
						
							|  |  |  | File.WriteAllBytes("SheetJSJurassic.ods", System.Convert.FromBase64String(ods)); | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | dotnet run pres.xlsx |