docs.sheetjs.com/tests/engines-rhino.sh

55 lines
1.5 KiB
Bash
Raw Normal View History

2024-05-26 07:50:55 +00:00
#!/bin/bash
# https://docs.sheetjs.com/docs/demos/engines/rhino
cd /tmp
rm -rf sheetjs-java
mkdir -p sheetjs-java
cd sheetjs-java
curl -L -o rhino.jar https://repo1.maven.org/maven2/org/mozilla/rhino/1.7.15/rhino-1.7.15.jar
2024-07-18 22:19:02 +00:00
curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js
2024-05-26 07:50:55 +00:00
curl -LO https://docs.sheetjs.com/pres.xlsx
curl -LO https://docs.sheetjs.com/rhino/SheetJSRhino.zip
unzip SheetJSRhino.zip
cat >SheetJSRhino.java <<EOF
/* sheetjs (C) 2013-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
import com.sheetjs.SheetJS;
import com.sheetjs.SheetJSFile;
import com.sheetjs.SheetJSSheet;
public class SheetJSRhino {
public static void main(String args[]) throws Exception {
try {
SheetJS sjs = new SheetJS();
/* open file */
SheetJSFile xl = sjs.read_file(args[0]);
/* get sheetnames */
String[] sheetnames = xl.get_sheet_names();
System.err.println(sheetnames[0]);
/* convert to CSV */
SheetJSSheet sheet = xl.get_sheet(0);
String csv = sheet.get_csv();
System.out.println(csv);
} catch(Exception e) { throw e; } finally { SheetJS.close(); }
}
}
EOF
for n in 1.8 {9..22}; do
2024-06-03 00:59:49 +00:00
export JAVA_HOME=`/usr/libexec/java_home -v $n`
java -version
2024-05-26 07:50:55 +00:00
find . -name \*.class | while read x; do rm $x; done
javac -cp ".:rhino.jar" SheetJSRhino.java
jar -cf SheetJS.jar SheetJSRhino.class com/sheetjs/*.class xlsx.full.min.js
java -cp ".:SheetJS.jar:rhino.jar" SheetJSRhino pres.xlsx
2024-06-25 07:16:41 +00:00
done