sheetjs-clone/demos/altjs/nashorn.js
SheetJS 5b67ac0806 version bump 0.11.2: proper plaintext parsing
- dollar currencies and percentages properly detected as numbers
- parse potential CDATA segments in XLSX (fixes #775 h/t @awb99)
- IE8 issues with regex
- altjs demos

Issues:
- fixes #673 h/t @huhm
- fixes #748 h/t @sangpuion
- fixes #749 h/t @GreggOD
- fixes #772 h/t @sangpuion @jyyan
2017-08-10 19:46:34 -04:00

29 lines
752 B
JavaScript

#!/usr/bin/env jjs
/* read file */
var path = java.nio.file.Paths.get('sheetjs.xlsx');
var fileArray = java.nio.file.Files.readAllBytes(path);
/* convert to plain JS array */
function b2a(b) {
var out = new Array(b.length);
for(var i = 0; i < out.length; i++) out[i] = b[i];
return out;
}
var u8a = b2a(fileArray);
/* load module */
load('./jvm-npm.js');
JSZip = require('../../jszip.js');
cptable = require('../../dist/cpexcel.js');
XLSX = require('../../xlsx.js');
/* read file */
var wb = XLSX.read(u8a, {type:"array"});
/* get first worksheet */
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)); });