added case for german languaged Worksheets #32

Closed
OliverZ wants to merge 0 commits from gh-pages into gh-pages
32 changed files with 3155 additions and 35839 deletions

30
.gitignore vendored
View File

@ -1,30 +0,0 @@
node_modules
package-lock.json
*.tgz
test_files/
_book/
misc/coverage.html
misc/prof.js
v8.log
tmp
*.[tT][xX][tT]
*.[cC][sS][vV]
*.[dD][iIbB][fF]
*.[pP][rR][nN]
*.[sS][lL][kK]
*.socialcalc
*.[xX][lL][sSwWcCaAtTmM]
*.[xX][lL][sSaAtT][xXmMbB]
*.[oO][dD][sS]
*.[fF][oO][dD][sS]
*.[xX][mM][lL]
*.[uU][oO][sS]
*.[wW][kKqQbB][S1234567890]
*.[qQ][pP][wW]
*.[bB][iI][fF][fF][23458]
*.[rR][tT][fF]
*.[eE][tT][hH]
*.123
*.sheetjs
*.exe
*.img

View File

@ -1,26 +0,0 @@
.PHONY: update
update:
git show master:index.html > index.html
git show master:dist/cpexcel.js > dist/cpexcel.js
git show master:dist/shim.min.js > dist/shim.min.js
git show master:dist/xlsx.core.min.js > dist/xlsx.core.min.js
git show master:dist/xlsx.full.min.js > dist/xlsx.full.min.js
git show master:dist/xlsx.core.min.js > xlsx.core.min.js
git show master:dist/xlsx.full.min.js > xlsx.full.min.js
git show master:xlsx.js > xlsx.js
git show master:shim.js > shim.js
git show master:shim.js > tests/shim.js
git show master:xlsxworker.js > xlsxworker.js
git show master:tests/base64.js > tests/base64.js
git show master:dist/xlsx.zahl.js > tests/xlsx.zahl.js
git show master:tests/core.js > tests/core.js
git show master:tests/fixtures.js > tests/fixtures.js
git show master:tests/fs_.js > tests/fs_.js
git show master:tests/mocha.css > tests/mocha.css
git show master:tests/mocha.js > tests/mocha.js
git show master:tests/write.js > tests/write.js
git show master:tests/write.html > tests/write.html
git show master:tests/index.html > tests/index.html
git show master:demos/datagrid/index.html > datagrid.html
git show master:demos/xspreadsheet/index.html > x-spreadsheet.html
git show master:demos/xspreadsheet/xlsxspread.js > xlsxspread.js

View File

@ -1,92 +0,0 @@
<!DOCTYPE html>
<!-- xlsx.js (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SheetJS JS-XLSX AJAX Live Demo</title>
<style>
a { text-decoration: none }
</style>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com">SheetJS AJAX Live Demo</a></b>
(this demo works back to IE6)
<a href="https://github.com/SheetJS/js-xlsx">Github Repo</a>
<a href="https://github.com/SheetJS/js-xlsx/issues">Issues? Something look weird? Click here and report an issue</a>
<br/><div id="fileurl"></div>
</pre>
<pre id="out"></pre>
<br />
<script src="iemagic.js"></script>
<script src="shim.js"></script>
<script src="xlsx.full.min.js"></script>
<script>
function to_csv(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]);
if(csv.length > 0){
result.push("SHEET: " + sheetName);
result.push("");
result.push(csv);
}
});
return result.join("\n");
}
function process_wb(wb) {
var output = to_csv(wb);
if(out.innerText === undefined) out.textContent = output;
else out.innerText = output;
if(typeof console !== 'undefined') console.log("output", new Date());
}
var url = "test_files/formula_stress_test_ajax.xlsx";
var oReq;
if(window.XMLHttpRequest) oReq = new XMLHttpRequest();
else if(window.ActiveXObject) oReq = new ActiveXObject('MSXML2.XMLHTTP.3.0');
else throw "XHR unavailable for your browser";
document.getElementById('fileurl').innerHTML = '<a href="' + url + '">Download file</a>';
oReq.open("GET", url, true);
if(typeof Uint8Array !== 'undefined') {
oReq.responseType = "arraybuffer";
oReq.onload = function(e) {
if(typeof console !== 'undefined') console.log("onload", new Date());
var arraybuffer = oReq.response;
var data = new Uint8Array(arraybuffer);
var wb = XLSX.read(data, {type:"array"});
process_wb(wb);
};
} else {
oReq.setRequestHeader("Accept-Charset", "x-user-defined");
oReq.onreadystatechange = function() { if(oReq.readyState == 4 && oReq.status == 200) {
var ff = convertResponseBodyToText(oReq.responseBody);
if(typeof console !== 'undefined') console.log("onload", new Date());
var wb = XLSX.read(ff, {type:"binary"});
process_wb(wb);
} };
}
oReq.send();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

View File

@ -1,162 +0,0 @@
<!DOCTYPE html>
<!-- xlsx.js (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SheetJS + canvas-datagrid Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
#b64data{
width:100%;
}
a { text-decoration: none }
</style>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com">SheetJS Data Preview Live Demo</a></b>
<a href="https://github.com/TonyGermaneri/canvas-datagrid">canvas-datagrid component library</a>
<a href="https://github.com/SheetJS/js-xlsx">Source Code Repo</a>
<a href="https://github.com/SheetJS/js-xlsx/issues">Issues? Something look weird? Click here and report an issue</a>
<div id="drop">Drop a spreadsheet file here to see sheet data</div>
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
<textarea id="b64data">... or paste a base64-encoding here</textarea>
<b>Advanced Demo Options:</b>
</pre>
<p><input type="submit" value="Export to XLSX!" id="xport" onclick="export_xlsx();" disabled="true"></p>
<div id="htmlout"></div>
<br />
<script src="https://unpkg.com/canvas-datagrid/dist/canvas-datagrid.js"></script>
<script src="shim.js"></script>
<script src="xlsx.full.min.js"></script>
<script>
/*jshint browser:true */
/* eslint-env browser */
/* eslint no-use-before-define:0 */
/*global Uint8Array, Uint16Array, ArrayBuffer */
/*global XLSX */
var cDg;
var process_wb = (function() {
var XPORT = document.getElementById('xport');
var HTMLOUT = document.getElementById('htmlout');
return function process_wb(wb) {
/* get data */
var ws = wb.Sheets[wb.SheetNames[0]];
var data = XLSX.utils.sheet_to_json(ws, {header:1});
/* update canvas-datagrid */
if(!cDg) cDg = canvasDatagrid({ parentNode:HTMLOUT, data:data });
cDg.style.height = '100%';
cDg.style.width = '100%';
cDg.data = data;
XPORT.disabled = false;
/* create schema (for A,B,C column headings) */
var range = XLSX.utils.decode_range(ws['!ref']);
for(var i = range.s.c; i <= range.e.c; ++i) cDg.schema[i - range.s.c].title = XLSX.utils.encode_col(i);
HTMLOUT.style.height = (window.innerHeight - 400) + "px";
HTMLOUT.style.width = (window.innerWidth - 50) + "px";
if(typeof console !== 'undefined') console.log("output", new Date());
};
})();
var do_file = (function() {
return function do_file(files) {
var f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
if(typeof console !== 'undefined') console.log("onload", new Date());
var data = e.target.result;
data = new Uint8Array(data);
process_wb(XLSX.read(data, {type: 'array'}));
};
reader.readAsArrayBuffer(f);
};
})();
(function() {
var drop = document.getElementById('drop');
if(!drop.addEventListener) return;
function handleDrop(e) {
e.stopPropagation();
e.preventDefault();
do_file(e.dataTransfer.files);
}
function handleDragover(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
drop.addEventListener('dragenter', handleDragover, false);
drop.addEventListener('dragover', handleDragover, false);
drop.addEventListener('drop', handleDrop, false);
})();
(function() {
var xlf = document.getElementById('xlf');
if(!xlf.addEventListener) return;
function handleFile(e) { do_file(e.target.files); }
xlf.addEventListener('change', handleFile, false);
})();
var export_xlsx = (function() {
function prep(arr) {
var out = [];
for(var i = 0; i < arr.length; ++i) {
if(!arr[i]) continue;
if(Array.isArray(arr[i])) { out[i] = arr[i]; continue };
var o = new Array();
Object.keys(arr[i]).forEach(function(k) { o[+k] = arr[i][k] });
out[i] = o;
}
return out;
}
return function export_xlsx() {
if(!cDg) return;
/* convert canvas-datagrid data to worksheet */
var new_ws = XLSX.utils.aoa_to_sheet(prep(cDg.data));
/* build workbook */
var new_wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(new_wb, new_ws, 'SheetJS');
/* write file and trigger a download */
XLSX.writeFile(new_wb, 'sheetjs.xlsx', {bookSST:true});
};
})();
</script>
<script type="text/javascript">
/* eslint no-use-before-define:0 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

1506
dist/cpexcel.js vendored

File diff suppressed because it is too large Load Diff

2
dist/shim.min.js vendored

File diff suppressed because one or more lines are too long

15
dist/xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

22
dist/xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,37 +0,0 @@
// http://stackoverflow.com/a/5913807
if(/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
var IEBinaryToArray_ByteStr_Script =
"<!-- IEBinaryToArray_ByteStr -->\r\n"+
"<script type='text/vbscript'>\r\n"+
"Function IEBinaryToArray_ByteStr(Binary)\r\n"+
" IEBinaryToArray_ByteStr = CStr(Binary)\r\n"+
"End Function\r\n"+
"Function IEBinaryToArray_ByteStr_Last(Binary)\r\n"+
" Dim lastIndex\r\n"+
" lastIndex = LenB(Binary)\r\n"+
" if lastIndex mod 2 Then\r\n"+
" IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n"+
" Else\r\n"+
" IEBinaryToArray_ByteStr_Last = "+'""'+"\r\n"+
" End If\r\n"+
"End Function\r\n"+
"</script>\r\n";
// inject VBScript
document.write(IEBinaryToArray_ByteStr_Script);
}
var convertResponseBodyToText = function (binary) {
var byteMapping = {};
for ( var i = 0; i < 256; i++ ) {
for ( var j = 0; j < 256; j++ ) {
byteMapping[ String.fromCharCode( i + j * 256 ) ] =
String.fromCharCode(i) + String.fromCharCode(j);
}
}
var rawBytes = IEBinaryToArray_ByteStr(binary);
var lastChr = IEBinaryToArray_ByteStr_Last(binary);
return rawBytes.replace(/[\s\S]/g,
function( match ) { return byteMapping[match]; }) + lastChr;
};

View File

@ -1,239 +1,136 @@
<!DOCTYPE html>
<!-- xlsx.js (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SheetJS Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
#b64data{
width:100%;
}
a { text-decoration: none }
#drop-zone{
background: white;
position: fixed;
top: 0px;
left: 0px;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
z-index: -1;
}
#drop-zone p, #drop-zone svg { pointer-events: none }
#drop-zone svg { margin-right: 5px }
</style>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com">SheetJS Data Preview Live Demo</a></b>
(Base64 text works back to IE6; drag and drop works back to IE10)
<a href="https://github.com/SheetJS/js-xlsx">Source Code Repo</a>
<a href="https://github.com/SheetJS/js-xlsx/issues">Issues? Something look weird? Click here and report an issue</a>
Output Format: <select name="format" onchange="setfmt()">
<option value="csv" selected> CSV</option>
<option value="json"> JSON</option>
<option value="form"> FORMULAE</option>
<option value="html"> HTML</option>
<option value="xlsx"> XLSX</option>
</select><br />
<input type="file" name="xlfile" id="xlf" />
<b> Drop a spreadsheet file anywhere in the page to see sheet data </b>
<b>JS-XLSX Live Demo</b><br />
<a href="https://github.com/Niggler/js-xlsx">Github Repo</a><br />
<a href="https://github.com/Niggler/js-xlsx/issues">Issues? Something look weird? Click here and report an issue</a><br />
<input type="radio" name="format" value="csv" checked> CSV<br>
<input type="radio" name="format" value="json"> JSON<br>
<input type="radio" name="format" value="form"> FORMULAE<br>
<div id="drop">Drop an XLSX file here to see sheet data.</div>
<textarea id="b64data">... or paste a base64-encoding here</textarea>
<input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br />
<b>Advanced Demo Options:</b>
Use Web Workers when available: <input type="checkbox" name="useworker" checked>
Always use UTF8 for CSV / text: <input type="checkbox" name="useutf8" checked>
</pre>
<input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/>
<pre id="out"></pre>
<div id="htmlout"></div>
<div id="drop-zone">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M17 13h-10v-1h10v1zm0-4h-10v1h10v-1zm0-3h-10v1h10v-1zm-15-1v-5h6v2h-4v3h-2zm8-5v2h4v-2h-4zm6 2h4v3h2v-5h-6v2zm6 5h-2v4h2v-4zm-20 10h2v-4h-2v4zm18-4v.543c0 4.107-6 2.457-6 2.457s1.518 6-2.638 6h-1.362v2h2.189c3.163 0 9.811-7.223 9.811-9.614v-1.386h-2zm-18-2h2v-4h-2v4zm2 11v-3h-2v5h6v-2h-4z"/></svg>
<p>Drop a spreadsheet file here to see sheet data</p>
</div>
<br />
<script src="dist/shim.min.js"></script>
<script src="dist/xlsx.full.min.js"></script>
<script src="jszip.js"></script>
<script src="xlsx.js"></script>
<script src="shim.js"></script>
<script>
/*jshint browser:true */
/* eslint-env browser */
/*global Uint8Array, Uint16Array, ArrayBuffer */
/*global XLSX */
/* eslint no-use-before-define:0 */
var global_wb;
var process_wb = (function() {
var OUT = document.getElementById('out');
var HTMLOUT = document.getElementById('htmlout');
var get_format = (function() {
var radios = document.getElementsByName( "format" );
return function() {
for(var i = 0; i < radios.length; ++i) if(radios[i].checked || radios.length === 1) return radios[i].value;
};
})();
var to_json = function to_json(workbook) {
var result = {};
workbook.SheetNames.forEach(function(sheetName) {
var roa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header:1});
if(roa.length) result[sheetName] = roa;
});
return JSON.stringify(result, 2, 2);
};
var to_csv = function to_csv(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]);
if(csv.length){
result.push("SHEET: " + sheetName);
result.push("");
result.push(csv);
}
});
return result.join("\n");
};
var to_fmla = function to_fmla(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var formulae = XLSX.utils.get_formulae(workbook.Sheets[sheetName]);
if(formulae.length){
result.push("SHEET: " + sheetName);
result.push("");
result.push(formulae.join("\n"));
}
});
return result.join("\n");
};
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = XLSX.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";
};
var to_xlsx = function to_xlsx(workbook) {
HTMLOUT.innerHTML = "";
XLSX.writeFile(workbook, "SheetJSTest.xlsx");
return "";
};
return function process_wb(wb) {
global_wb = wb;
var output = "";
switch(get_format()) {
case "form": output = to_fmla(wb); break;
case "html": output = to_html(wb); break;
case "json": output = to_json(wb); break;
case "xlsx": output = to_xlsx(wb); break;
default: output = to_csv(wb);
function get_radio_value( radioName ) {
var radios = document.getElementsByName( radioName );
for( var i = 0; i < radios.length; i++ ) {
if( radios[i].checked ) {
return radios[i].value;
}
if(OUT.innerText === undefined) OUT.textContent = output;
else OUT.innerText = output;
if(typeof console !== 'undefined') console.log("output", new Date());
};
})();
}
}
var setfmt = window.setfmt = function setfmt() { if(global_wb) process_wb(global_wb); };
function to_json(workbook) {
var result = {};
workbook.SheetNames.forEach(function(sheetName) {
var roa = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
if(roa.length > 0){
result[sheetName] = roa;
}
});
return result;
}
var b64it = window.b64it = (function() {
var tarea = document.getElementById('b64data');
return function b64it() {
if(typeof console !== 'undefined') console.log("onload", new Date());
var wb = XLSX.read(tarea.value, {type:'base64', WTF:false});
process_wb(wb);
};
})();
function to_csv(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]);
if(csv.length > 0){
result.push("SHEET: " + sheetName);
result.push("");
result.push(csv);
}
});
return result.join("\n");
}
var do_file = (function() {
var use_worker = typeof Worker !== 'undefined';
var domwork = document.getElementsByName("useworker")[0];
if(!use_worker) domwork.disabled = !(domwork.checked = false);
function to_formulae(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var formulae = XLSX.utils.get_formulae(workbook.Sheets[sheetName]);
if(formulae.length > 0){
result.push("SHEET: " + sheetName);
result.push("");
result.push(formulae.join("\n"));
}
});
return result.join("\n");
}
var use_utf8 = false;
var tarea = document.getElementById('b64data');
function b64it() {
var wb = XLSX.read(tarea.value, {type: 'base64'});
process_wb(wb);
}
var xw = function xw(data, cb) {
var worker = new Worker('./xlsxworker.js');
worker.onmessage = function(e) {
switch(e.data.t) {
case 'ready': break;
case 'e': console.error(e.data.d); break;
case 'xlsx': cb(JSON.parse(e.data.d)); break;
}
};
worker.postMessage({d:data,b:'array',c:use_utf8 ? 65001 : void 0});
};
function process_wb(wb) {
var output = "";
switch(get_radio_value("format")) {
case "json":
output = JSON.stringify(to_json(wb), 2, 2);
break;
case "form":
output = to_formulae(wb);
break;
default:
output = to_csv(wb);
}
if(out.innerText === undefined) out.textContent = output;
else out.innerText = output;
}
return function do_file(files) {
use_worker = domwork.checked;
use_utf8 = document.getElementsByName("useutf8")[0].checked;
var f = files[0];
var drop = document.getElementById('drop');
function handleDrop(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;
var i,f;
for (i = 0, f = files[i]; i != files.length; ++i) {
var reader = new FileReader();
var name = f.name;
reader.onload = function(e) {
if(typeof console !== 'undefined') console.log("onload", new Date(), use_worker);
var data = new Uint8Array(e.target.result);
if(use_worker) xw(data, process_wb);
else process_wb(XLSX.read(data, {type: 'array', codepage: use_utf8 ? 65001 : void 0}));
var data = e.target.result;
//var wb = XLSX.read(data, {type: 'binary'});
var arr = String.fromCharCode.apply(null, new Uint8Array(data));
var wb = XLSX.read(btoa(arr), {type: 'base64'});
process_wb(wb);
};
//reader.readAsBinaryString(f);
reader.readAsArrayBuffer(f);
};
})();
(function() {
var dropZone = document.getElementById('drop-zone')
if(!dropZone.addEventListener && !window.addEventListener) return;
function handleDrop(e) {
dropZoneDisplay(e, false);
do_file(e.dataTransfer.files);
}
}
function handleDragover(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
function handleDragover(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
function dropZoneDisplay(e, show){
e.stopPropagation();
e.preventDefault();
var opacity = show ? '1' : '0';
var zIndex = show ? '1' : '-1';
dropZone.style.opacity = opacity;
dropZone.style.zIndex = zIndex;
}
window.addEventListener('drop' , handleDrop)
window.addEventListener('dragover' , handleDragover)
window.addEventListener('dragenter' , function(e){
dropZoneDisplay(e, true);
})
dropZone.addEventListener('dragleave' , function(e){
dropZoneDisplay(e, false);
})
})();
(function() {
var xlf = document.getElementById('xlf');
if(!xlf.addEventListener) return;
function handleFile(e) { do_file(e.target.files); }
xlf.addEventListener('change', handleFile, false);
})();
if(drop.addEventListener) {
drop.addEventListener('dragenter', handleDragover, false);
drop.addEventListener('dragover', handleDragover, false);
drop.addEventListener('drop', handleDrop, false);
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
@ -244,5 +141,3 @@ var do_file = (function() {
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

2128
jszip.js Normal file

File diff suppressed because it is too large Load Diff

295
shim.js
View File

@ -1,154 +1,145 @@
/*! shim.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* ES3/5 Compatibility shims and other utilities for older browsers. */
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if(!Object.keys) Object.keys = (function() {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function(obj) {
if(typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object');
var result = [];
for(var prop in obj) if(hasOwnProperty.call(obj, prop)) result.push(prop);
if(hasDontEnumBug)
for(var i=0; i < dontEnumsLength; ++i)
if(hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
return result;
};
})();
if(!String.prototype.trim) String.prototype.trim = function() {
var s = this.replace(/^\s+/, '');
for(var i = s.length - 1; i >=0 ; --i) if(!s.charAt(i).match(/^\s/)) return s.slice(0,i+1);
return "";
};
if(!Array.prototype.forEach) Array.prototype.forEach = function(cb) {
var len = (this.length>>>0), self = (arguments[1]||void 0);
for(var i=0; i<len; ++i) if(i in this) self ? cb.call(self, this[i], i, this) : cb(this[i], i, this);
};
if(!Array.prototype.map) Array.prototype.map = function(cb) {
var len = (this.length>>>0), self = (arguments[1]||void 0), A = new Array(len);
for(var i=0; i<len; ++i) if(i in this) A[i] = self ? cb.call(self, this[i], i, this) : cb(this[i], i, this);
return A;
};
if(!Array.prototype.indexOf) Array.prototype.indexOf = function(needle) {
var len = (this.length>>>0), i = ((arguments[1]|0)||0);
for(i<0 && (i+=len)<0 && (i=0); i<len; ++i) if(this[i] === needle) return i;
return -1;
};
if(!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(needle) {
var len = (this.length>>>0), i = len - 1;
for(; i>=0; --i) if(this[i] === needle) return i;
return -1;
};
if(!Array.isArray) Array.isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; };
if(!Date.prototype.toISOString) Date.prototype.toISOString = (function() {
function p(n,i) { return ('0000000' + n).slice(-(i||2)); }
return function _toISOString() {
var y = this.getUTCFullYear(), yr = "";
if(y>9999) yr = '+' + p( y, 6);
else if(y<0) yr = '-' + p(-y, 6);
else yr = p( y, 4);
return [
yr, p(this.getUTCMonth()+1), p(this.getUTCDate())
].join('-') + 'T' + [
p(this.getUTCHours()), p(this.getUTCMinutes()), p(this.getUTCSeconds())
].join(':') + '.' + p(this.getUTCMilliseconds(),3) + 'Z';
};
}());
if(typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) ArrayBuffer.prototype.slice = function(start, end) {
if(start == null) start = 0;
if(start < 0) { start += this.byteLength; if(start < 0) start = 0; }
if(start >= this.byteLength) return new Uint8Array(0);
if(end == null) end = this.byteLength;
if(end < 0) { end += this.byteLength; if(end < 0) end = 0; }
if(end > this.byteLength) end = this.byteLength;
if(start > end) return new Uint8Array(0);
var out = new ArrayBuffer(end - start);
var view = new Uint8Array(out);
var data = new Uint8Array(this, start, end - start)
/* IE10 should have Uint8Array#set */
if(view.set) view.set(data); else while(start <= --end) view[end - start] = data[end];
return out;
};
if(typeof Uint8Array !== 'undefined' && !Uint8Array.prototype.slice) Uint8Array.prototype.slice = function(start, end) {
if(start == null) start = 0;
if(start < 0) { start += this.length; if(start < 0) start = 0; }
if(start >= this.length) return new Uint8Array(0);
if(end == null) end = this.length;
if(end < 0) { end += this.length; if(end < 0) end = 0; }
if(end > this.length) end = this.length;
if(start > end) return new Uint8Array(0);
var out = new Uint8Array(end - start);
while(start <= --end) out[end - start] = this[end];
return out;
};
// VBScript + ActiveX fallback for IE5+
var IE_SaveFile = (function() { try {
if(typeof IE_SaveFile_Impl == "undefined") document.write([
'<script type="text/vbscript" language="vbscript">',
'IE_GetProfileAndPath_Key = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\"',
'Function IE_GetProfileAndPath(key): Set wshell = CreateObject("WScript.Shell"): IE_GetProfileAndPath = wshell.RegRead(IE_GetProfileAndPath_Key & key): IE_GetProfileAndPath = wshell.ExpandEnvironmentStrings("%USERPROFILE%") & "!" & IE_GetProfileAndPath: End Function',
'Function IE_SaveFile_Impl(FileName, payload): Dim data, plen, i, bit: data = CStr(payload): plen = Len(data): Set fso = CreateObject("Scripting.FileSystemObject"): fso.CreateTextFile FileName, True: Set f = fso.GetFile(FileName): Set stream = f.OpenAsTextStream(2, 0): For i = 1 To plen Step 3: bit = Mid(data, i, 2): stream.write Chr(CLng("&h" & bit)): Next: stream.Close: IE_SaveFile_Impl = True: End Function',
'|/script>'.replace("|","<")
].join("\r\n"));
if(typeof IE_SaveFile_Impl == "undefined") return void 0;
var IE_GetPath = (function() {
var DDP1 = "";
try { DDP1 = IE_GetProfileAndPath("{374DE290-123F-4565-9164-39C4925E467B}"); } catch(e) { try { DDP1 = IE_GetProfileAndPath("Personal"); } catch(e) { try { DDP1 = IE_GetProfileAndPath("Desktop"); } catch(e) { throw e; }}}
var o = DDP1.split("!");
DDP = o[1].replace("%USERPROFILE%", o[0]);
return function(path) { return DDP + "\\" + path; };
if (!Object.keys) {
Object.keys = (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function (obj) {
if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object');
var result = [];
for (var prop in obj) {
if (hasOwnProperty.call(obj, prop)) result.push(prop);
}
if (hasDontEnumBug) {
for (var i=0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
}
}
return result;
};
})();
function fix_data(data) {
var out = [];
var T = typeof data == "string";
for(var i = 0; i < data.length; ++i) out.push(("00"+(T ? data.charCodeAt(i) : data[i]).toString(16)).slice(-2));
var o = out.join("|");
return o;
}
return function(data, filename) { return IE_SaveFile_Impl(IE_GetPath(filename), fix_data(data)); };
} catch(e) { return void 0; }})();
var IE_LoadFile = (function() { try {
if(typeof IE_LoadFile_Impl == "undefined") document.write([
'<script type="text/vbscript" language="vbscript">',
'Function IE_LoadFile_Impl(FileName): Dim out(), plen, i, cc: Set fso = CreateObject("Scripting.FileSystemObject"): Set f = fso.GetFile(FileName): Set stream = f.OpenAsTextStream(1, 0): plen = f.Size: ReDim out(plen): For i = 1 To plen Step 1: cc = Hex(Asc(stream.read(1))): If Len(cc) < 2 Then: cc = "0" & cc: End If: out(i) = cc: Next: IE_LoadFile_Impl = Join(out,""): End Function',
'|/script>'.replace("|","<")
].join("\r\n"));
if(typeof IE_LoadFile_Impl == "undefined") return void 0;
function fix_data(data) {
var out = [];
for(var i = 0; i < data.length; i+=2) out.push(String.fromCharCode(parseInt(data.slice(i, i+2), 16)));
var o = out.join("");
return o;
}
return function(filename) { return fix_data(IE_LoadFile_Impl(filename)); };
} catch(e) { return void 0; }})();
// getComputedStyle polyfill from https://gist.github.com/8HNHoFtE/5891086
if(typeof window !== 'undefined' && typeof window.getComputedStyle !== 'function') {
window.getComputedStyle = function(e,t){return this.el=e,this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),n.test(t)&&(t=t.replace(n,function(){return arguments[2].toUpperCase()})),e.currentStyle[t]?e.currentStyle[t]:null},this}
}
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
if ( !Array.prototype.forEach ) {
Array.prototype.forEach = function(fn, scope) {
for(var i = 0, len = this.length; i < len; ++i) {
fn.call(scope, this[i], i, this);
}
};
}
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.com/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function(callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len) where Array is
// the standard built-in constructor with that name and len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while(k < len) {
var kValue, mappedValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[ k ];
// ii. Let mappedValue be the result of calling the Call internal method of callback
// with T as the this value and argument list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
// For best browser support, use the following:
A[ k ] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}

View File

@ -1,67 +0,0 @@
// https://github.com/davidchambers/Base64.js
// (C) 2015 David Chambers and contributors
// Base64.js may be freely distributed under the Apache 2.0 License.
;(function () {
var object =
typeof exports != 'undefined' ? exports :
typeof self != 'undefined' ? self : // #8: web workers
$.global; // #31: ExtendScript
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function InvalidCharacterError(message) {
this.message = message;
}
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
// encoder
// [https://gist.github.com/999166] by [https://github.com/nignag]
object.btoa || (
object.btoa = function (input) {
var str = String(input);
for (
// initialize result and counter
var block, charCode, idx = 0, map = chars, output = '';
// if the next str index does not exist:
// change the mapping table to "="
// check if d has no fractional digits
str.charAt(idx | 0) || (map = '=', idx % 1);
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
) {
charCode = str.charCodeAt(idx += 3/4);
if (charCode > 0xFF) {
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
}
block = block << 8 | charCode;
}
return output;
});
// decoder
// [https://gist.github.com/1020396] by [https://github.com/atk]
object.atob || (
object.atob = function (input) {
var str = String(input).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=
if (str.length % 4 == 1) {
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
}
for (
// initialize result and counters
var bc = 0, bs, buffer, idx = 0, output = '';
// get next character
buffer = str.charAt(idx++);
// character found in table? initialize bit storage and add its ascii value;
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
// and if not first of each 4 characters,
// convert the first 8 bits to one ascii character
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
) {
// try to find character in table (0-63, not found => -1)
buffer = chars.indexOf(buffer);
}
return output;
});
}());

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,48 +0,0 @@
var assert = function(bool) { if(!bool) { throw new Error("failed assert"); } };
assert.deepEqualArray = function(x,y) {
if(x.length != y.length) throw new Error("Length mismatch: " + x.length + " != " + y.length);
for(var i = 0; i < x.length; ++i) assert.deepEqual(x[i], y[i]);
};
assert.deepEqual = function(x,y) {
if(x == y) return true;
if(Array.isArray(x) && Array.isArray(y) && x.length > 5) return assert.deepEqualArray(x,y);
if(typeof x != 'object' || typeof y != 'object') throw new Error(x + " !== " + y);
Object.keys(x).forEach(function(k) { assert.deepEqual(x[k], y[k]); });
Object.keys(y).forEach(function(k) { assert.deepEqual(x[k], y[k]); });
};
assert.notEqual = function(x,y) { if(x == y) throw new Error(x + " == " + y); };
assert.equal = function(x,y) { if(x != y) throw new Error(x + " !== " + y); };
assert.throws = function(cb) { var pass = true; try { cb(); pass = false; } catch(e) { } if(!pass) throw new Error("Function did not throw"); };
assert.doesNotThrow = function(cb) { var pass = true; try { cb(); } catch(e) { pass = false; } if(!pass) throw new Error("Function did throw"); };
function require(s) {
switch(s) {
case 'fs': return fs;
case 'assert': return assert;
case './': return XLSX;
}
if(s.slice(-5) == ".json") return JSON.parse(fs.readFileSync(s));
}
var fs = {};
fs.existsSync = function(p) { return !!fs[p]; };
fs.readdirSync = function(p) {
var k = Object.keys(fs), o = [];
for(var i = 0; i < k.length; ++i) if(fs.hasOwnProperty(k[i]) && k[i].match(p)) o.push(k[i]);
return o;
};
fs.readFileSync = function(f, enc) {
if(!fs[f]) throw new Error("File not found: " + f);
fs[f].length;
switch(enc) {
case 'base64': return fs[f];
case 'buffer':
var o = atob(fs[f]), oo = [];
for(var i = 0; i < o.length; ++i) oo[i] = o.charCodeAt(i);
return oo;
default: return atob(fs[f]);
}
};
fs.writeFileSync = function(f, d) { fs[f] = d; };

View File

@ -1,57 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>JS-XLSX Core Test Runner</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="mocha.css" />
<link rel="icon" type="image/png" href="//oss.sheetjs.com/assets/img/logo.png" />
<style>
#t { font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; margin: 0px 60px; font-weight: bold; }
#tt{ font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; margin: 0px 60px; }
th { font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; margin: 0px 60px; font-weight: bold; text-align: left; }
</style>
</head>
<body>
<h1 id="t"><a href="http://sheetjs.com">JS-XLSX Browser-based Parsing Tests</a></h1>
<table id="tt">
<tr>
<th>File Formats</th>
<td><a href="http://github.com/SheetJS/js-xlsx">Library Source</a></td>
<td><a href="http://SheetJS.github.io/js-xls">Interactive Demo</a></td>
<td><a href="http://npm.im/xlsx">"xlsx" on npm</a></td>
<td><a href="https://travis-ci.org/SheetJS/js-xlsx">node CI status</a></td>
</tr>
<tr><td colspan="5">Tests compiled from <a href="http://github.com/SheetJS/test_files">test_files repo</a> and are located at /test_files<br /></td></tr>
</table>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="shim.js"></script>
<script src="base64.js"></script>
<script src="fs_.js"></script>
<script src="fixtures.js"></script>
<script src="xlsx.zahl.js"></script>
<script src="xlsx.full.min.js"></script>
<div id="mocha"></div>
<script src="mocha.js"></script>
<script>
window.initMochaPhantomJS && window.initMochaPhantomJS();
mocha.setup({ui:'bdd', timeout:15000});
</script>
<script src="core.js"></script>
<script>
if(typeof mochaSaucePlease !== "undefined") mochaSaucePlease();
else if(window.mochaPhantomJS) mochaPhantomJS.run();
else typeof mocha_sauce !== 'undefined' ? mocha_sauce() : mocha.run();
</script>
</body>
</html>

View File

@ -1,260 +0,0 @@
@charset "utf-8";
body {
margin:0;
}
#mocha {
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 60px 50px;
}
#mocha ul, #mocha li {
margin: 0;
padding: 0;
}
#mocha ul {
list-style: none;
}
#mocha h1, #mocha h2 {
margin: 0;
}
#mocha h1 {
margin-top: 15px;
font-size: 1em;
font-weight: 200;
}
#mocha h1 a {
text-decoration: none;
color: inherit;
}
#mocha h1 a:hover {
text-decoration: underline;
}
#mocha .suite .suite h1 {
margin-top: 0;
font-size: .8em;
}
#mocha .hidden {
display: none;
}
#mocha h2 {
font-size: 12px;
font-weight: normal;
cursor: pointer;
}
#mocha .suite {
margin-left: 15px;
}
#mocha .test {
margin-left: 15px;
overflow: hidden;
}
#mocha .test.pending:hover h2::after {
content: '(pending)';
font-family: arial, sans-serif;
}
#mocha .test.pass.medium .duration {
background: #C09853;
}
#mocha .test.pass.slow .duration {
background: #B94A48;
}
#mocha .test.pass::before {
content: '✓';
font-size: 12px;
display: block;
float: left;
margin-right: 5px;
color: #00d6b2;
}
#mocha .test.pass .duration {
font-size: 9px;
margin-left: 5px;
padding: 2px 5px;
color: white;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
}
#mocha .test.pass.fast .duration {
display: none;
}
#mocha .test.pending {
color: #0b97c4;
}
#mocha .test.pending::before {
content: '◦';
color: #0b97c4;
}
#mocha .test.fail {
color: #c00;
}
#mocha .test.fail pre {
color: black;
}
#mocha .test.fail::before {
content: '✖';
font-size: 12px;
display: block;
float: left;
margin-right: 5px;
color: #c00;
}
#mocha .test pre.error {
color: #c00;
max-height: 300px;
overflow: auto;
}
#mocha .test pre {
display: block;
float: left;
clear: left;
font: 12px/1.5 monaco, monospace;
margin: 5px;
padding: 15px;
border: 1px solid #eee;
border-bottom-color: #ddd;
-webkit-border-radius: 3px;
-webkit-box-shadow: 0 1px 3px #eee;
-moz-border-radius: 3px;
-moz-box-shadow: 0 1px 3px #eee;
border-radius: 3px;
}
#mocha .test h2 {
position: relative;
}
#mocha .test a.replay {
position: absolute;
top: 3px;
right: 0;
text-decoration: none;
vertical-align: middle;
display: block;
width: 15px;
height: 15px;
line-height: 15px;
text-align: center;
background: #eee;
font-size: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-transition: opacity 200ms;
-moz-transition: opacity 200ms;
transition: opacity 200ms;
opacity: 0.3;
color: #888;
}
#mocha .test:hover a.replay {
opacity: 1;
}
#mocha-report.pass .test.fail {
display: none;
}
#mocha-report.fail .test.pass {
display: none;
}
#mocha-report.pending .test.pass,
#mocha-report.pending .test.fail {
display: none;
}
#mocha-report.pending .test.pass.pending {
display: block;
}
#mocha-error {
color: #c00;
font-size: 1.5em;
font-weight: 100;
letter-spacing: 1px;
}
#mocha-stats {
position: fixed;
top: 15px;
right: 10px;
font-size: 12px;
margin: 0;
color: #888;
z-index: 1;
}
#mocha-stats .progress {
float: right;
padding-top: 0;
}
#mocha-stats em {
color: black;
}
#mocha-stats a {
text-decoration: none;
color: inherit;
}
#mocha-stats a:hover {
border-bottom: 1px solid #eee;
}
#mocha-stats li {
display: inline-block;
margin: 0 5px;
list-style: none;
padding-top: 11px;
}
#mocha-stats canvas {
width: 40px;
height: 40px;
}
#mocha code .comment { color: #ddd }
#mocha code .init { color: #2F6FAD }
#mocha code .string { color: #5890AD }
#mocha code .keyword { color: #8A6343 }
#mocha code .number { color: #2F6FAD }
@media screen and (max-device-width: 480px) {
#mocha {
margin: 60px 0px;
}
#mocha #stats {
position: absolute;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
../shim.js

View File

@ -1,44 +0,0 @@
<!DOCTYPE html>
<!-- (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<title>SheetJS JS-XLSX In-Browser Export Demo</title>
<meta charset="utf-8" />
<style>
a { text-decoration: none }
</style>
</head>
<body>
<pre>
<h3><a href="//sheetjs.com/">SheetJS</a> JS-XLSX In-Browser Export Demo</h3>
<b>Example Code</b>
/* Generate Workbook */
var wb = XLSX.utils.book_new();
var ws = XLSX.utils.aoa_to_sheet([["a","b"],[1,2,3]]);
XLSX.utils.book_append_sheet(wb, ws, "SheetJS");
/* Trigger Download with `writeFile` */
XLSX.writeFile(wb, "SheetJS.xlsb", {compression:true});
<b>Download Generation Methods:</b>
- IE6-9 require ActiveX and Windows Script support.
The IE_SaveFile function from the included shim uses VBScript.
- IE10-11 use msSaveBlob API.
- When supported, `saveAs` will be used.
- When available, modern browsers use `URL.createObjectURL`.
<b>Multiple Download Caveat</b>
Some browsers warn or block attempts to download multiple files. Chrome content
settings support whitelisting domains for automatic multiple downloads.
</pre>
<script src="shim.js"></script>
<script src="xlsx.full.min.js"></script>
<script src="write.js"></script>
</body>

View File

@ -1,214 +0,0 @@
/* writing feature test -- look for TEST: in comments */
/* vim: set ts=2 ft=javascript: */
if(typeof console === 'undefined') console = {log: function(){}};
var ext = typeof process !== 'undefined' && !!process.argv[2];
/* original data */
var data = [
[1, 2, 3],
[true, false, null, "sheetjs"],
["foo bar", "baz", new Date("2014-02-19T14:30Z"), "0.3"],
["baz", null, "\u0BEE", 3.14159],
["hidden"],
["visible"]
];
if(isNaN(data[2][2].getYear())) data[2][2] = new Date(Date.UTC(2014, 1, 19, 14, 30, 0));
var ws_name = "SheetJS";
var wscols = [
{wch: 6}, // "characters"
{wpx: 50}, // "pixels"
,
{hidden: true} // hide column
];
/* At 96 PPI, 1 pt = 1 px */
var wsrows = [
{hpt: 12}, // "points"
{hpx: 16}, // "pixels"
,
{hpx: 24, level:3},
{hidden: true}, // hide row
{hidden: false}
];
console.log("Sheet Name: " + ws_name);
console.log("Data: ");
var i = 0;
for(i = 0; i !== data.length; ++i) console.log(data[i]);
console.log("Columns :");
for(i = 0; i !== wscols.length; ++i) console.log(wscols[i]);
/* require XLSX */
if(typeof XLSX === "undefined") { try { XLSX = require('./'); } catch(e) { XLSX = require('../'); } }
/* blank workbook constructor */
/*
var wb = { SheetNames: [], Sheets: {} };
*/
var wb = XLSX.utils.book_new();
/* convert an array of arrays in JS to a CSF spreadsheet */
var ws = XLSX.utils.aoa_to_sheet(data, {cellDates:true});
/* TEST: add worksheet to workbook */
/*
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
*/
XLSX.utils.book_append_sheet(wb, ws, ws_name);
/* TEST: simple formula */
ws['C1'].f = "A1+B1";
ws['C2'] = {t:'n', f:"A1+B1"};
/* TEST: single-cell array formula */
/*
ws['D1'] = {t:'n', f:"SUM(A1:C1*A1:C1)", F:"D1:D1"};
*/
XLSX.utils.sheet_set_array_formula(ws, 'D1:D1', "SUM(A1:C1*A1:C1)");
/* TEST: multi-cell array formula */
/*
ws['E1'] = {t:'n', f:"TRANSPOSE(A1:D1)", F:"E1:E4"};
ws['E2'] = {t:'n', F:"E1:E4"};
ws['E3'] = {t:'n', F:"E1:E4"};
ws['E4'] = {t:'n', F:"E1:E4"};
*/
XLSX.utils.sheet_set_array_formula(ws, 'E1:E4', "TRANSPOSE(A1:D1)");
ws["!ref"] = "A1:E6";
/* TEST: column props */
ws['!cols'] = wscols;
/* TEST: row props */
ws['!rows'] = wsrows;
/* TEST: hyperlink note: Excel does not automatically style hyperlinks */
/*
ws['A4'].l = { Target: "#E2" };
*/
XLSX.utils.cell_set_internal_link(ws['A4'], "E2");
/*
ws['A3'].l = { Target: "http://sheetjs.com", Tooltip: "Visit us <SheetJS.com!>" };
*/
XLSX.utils.cell_set_hyperlink(ws['A3'], "http://sheetjs.com", "Visit us <SheetJS.com!>");
/* TEST: built-in format */
/*
ws['B1'].z = "0%"; // Format Code 9
*/
XLSX.utils.cell_set_number_format(ws['B1'], "0%");
/* TEST: custom format */
var custfmt = "\"This is \"\\ 0.0";
/*
ws['C2'].z = custfmt;
*/
XLSX.utils.cell_set_number_format(ws['C2'], custfmt);
/* TEST: page margins */
ws['!margins'] = { left:1.0, right:1.0, top:1.0, bottom:1.0, header:0.5, footer:0.5 };
/* TEST: merge cells */
ws['!merges'] = [ XLSX.utils.decode_range("A6:C6") ];
console.log("JSON Data:");
console.log(XLSX.utils.sheet_to_json(ws, {header:1}));
/* TEST: hidden sheets */
/*
wb.SheetNames.push("Hidden");
wb.Sheets["Hidden"] = XLSX.utils.aoa_to_sheet(["Hidden".split(""), [1,2,3]]);
wb.Workbook = {Sheets:[]};
wb.Workbook.Sheets[1] = {Hidden:1};
*/
var data_2 = ["Hidden".split(""), [1,true,3,'a',,'c'], [2,false,true,'sh33t',,'j5']];
XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(data_2), "Hidden");
XLSX.utils.book_set_sheet_visibility(wb, "Hidden", XLSX.utils.consts.SHEET_HIDDEN);
/* TEST: properties */
wb.Props = {
Title: "SheetJS Test",
Subject: "Tests",
Author: "Devs at SheetJS",
Manager: "Sheet Manager",
Company: "SheetJS",
Category: "Experimentation",
Keywords: "Test",
Comments: "Nothing to say here",
LastAuthor: "Not SheetJS",
CreatedDate: new Date(2017,1,19)
};
/* TEST: comments */
/*
ws['A4'].c = [];
ws['A4'].c.push({a:"SheetJS",t:"I'm a little comment, short and stout!\n\nWell, Stout may be the wrong word"});
*/
XLSX.utils.cell_add_comment(ws['A4'], "I'm a little comment, short and stout!\n\nWell, Stout may be the wrong word", "SheetJS");
/* TEST: sheet protection */
ws['!protect'] = {
password:"password",
/* enable formatting rows and columns */
formatRows:false,
formatColumns:false,
/* disable editing objects and scenarios */
objects:true,
scenarios:true
};
/* TEST: Workbook Properties */
if(!wb.Workbook) wb.Workbook = {Sheets:[], WBProps:{}};
if(!wb.Workbook.WBProps) wb.Workbook.WBProps = {};
wb.Workbook.WBProps.filterPrivacy = true;
if(ext) wb.Workbook.Views = [{RTL:true}];
console.log("Worksheet Model:");
console.log(ws);
var filenames = [
['sheetjs.xlsx', {bookSST:true}],
['sheetjs.xlsm'],
['sheetjs.xlsb'],
['sheetjs.xlam'],
['sheetjs.biff8.xls', {bookType:'xls'}],
['sheetjs.biff5.xls', {bookType:'biff5'}],
['sheetjs.biff2.xls', {bookType:'biff2'}],
['sheetjs.xml.xls', {bookType:'xlml'}],
['sheetjs.xla'],
['sheetjs.ods'],
['sheetjs.fods'],
['sheetjs.csv'],
['sheetjs.txt'],
['sheetjs.slk'],
['sheetjs.eth'],
['sheetjs.htm'],
['sheetjs.dif'],
['sheetjs.dbf', {sheet:"Hidden"}],
['sheetjs.rtf'],
['sheetjs.prn']
];
var OUT = ["base64", "binary", "string", "array"];
if(typeof Buffer !== 'undefined') OUT.push("buffer");
filenames.forEach(function(r) {
/* write file */
XLSX.writeFile(wb, r[0], r[1]);
/* test by reading back files */
if(typeof process !== 'undefined') XLSX.readFile(r[0]);
var ext = r[1] && r[1].bookType || r[0].split(".")[1];
ext = {"htm":"html"}[ext] || ext;
OUT.forEach(function(type) {
if(type == "string" && ["xlsx", "xlsm", "xlsb", "xlam", "biff8", "biff5", "biff2", "xla", "ods", "dbf"].indexOf(ext) > -1) return;
if(type == "array" && ["xlsx", "xlsm", "xlsb", "xlam", "ods"].indexOf(ext) > -1 && typeof Uint8Array === 'undefined') return;
var datout = XLSX.write(wb, {type: type, bookType: ext, sheet:r[1] && r[1].sheet || null});
XLSX.read(datout, {type:type});
if(type == "array") console.log(ext, datout);
});
});

View File

@ -1 +0,0 @@
../xlsx.full.min.js

File diff suppressed because one or more lines are too long

View File

@ -1,135 +0,0 @@
<!DOCTYPE html>
<!-- xlsx.js (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SheetJS + x-spreadsheet Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
#b64data{
width:100%;
}
a { text-decoration: none }
</style>
<!-- x-spreadsheet stylesheet -->
<link rel="stylesheet" href="https://unpkg.com/x-data-spreadsheet/dist/xspreadsheet.css"/>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com">SheetJS Data Preview Live Demo</a></b>
<a href="https://github.com/myliang/x-spreadsheet">x-spreadsheet component library</a>
<a href="https://github.com/SheetJS/sheetjs">Source Code Repo</a>
<a href="https://github.com/SheetJS/sheetjs/issues">Issues? Something look weird? Click here and report an issue</a>
<div id="drop">Drop a spreadsheet file here to see sheet data</div>
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
<textarea id="b64data">... or paste a base64-encoding here</textarea>
</pre>
<p><input type="submit" value="Export to XLSX!" id="xport" onclick="export_xlsx();"></p>
<div id="htmlout"></div>
<br />
<script src="https://unpkg.com/x-data-spreadsheet/dist/xspreadsheet.js"></script>
<script src="shim.js"></script>
<script src="xlsx.full.min.js"></script>
<script src="xlsxspread.js"></script>
<script>
/*jshint browser:true */
/* eslint-env browser */
/* eslint no-use-before-define:0 */
/*global Uint8Array, Uint16Array, ArrayBuffer */
/*global XLSX */
var HTMLOUT = document.getElementById('htmlout');
var xspr = x_spreadsheet(HTMLOUT);
HTMLOUT.style.height = (window.innerHeight - 400) + "px";
HTMLOUT.style.width = (window.innerWidth - 50) + "px";
var process_wb = (function() {
var XPORT = document.getElementById('xport');
return function process_wb(wb) {
/* convert to x-spreadsheet form */
var data = stox(wb);
/* update x-spreadsheet */
xspr.loadData(data);
XPORT.disabled = false;
if(typeof console !== 'undefined') console.log("output", new Date());
};
})();
var do_file = (function() {
return function do_file(files) {
var f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
if(typeof console !== 'undefined') console.log("onload", new Date());
var data = e.target.result;
data = new Uint8Array(data);
process_wb(XLSX.read(data, {type: 'array'}));
};
reader.readAsArrayBuffer(f);
};
})();
(function() {
var drop = document.getElementById('drop');
if(!drop.addEventListener) return;
function handleDrop(e) {
e.stopPropagation();
e.preventDefault();
do_file(e.dataTransfer.files);
}
function handleDragover(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
drop.addEventListener('dragenter', handleDragover, false);
drop.addEventListener('dragover', handleDragover, false);
drop.addEventListener('drop', handleDrop, false);
})();
(function() {
var xlf = document.getElementById('xlf');
if(!xlf.addEventListener) return;
function handleFile(e) { do_file(e.target.files); }
xlf.addEventListener('change', handleFile, false);
})();
function export_xlsx() {
var new_wb = xtos(xspr.getData());
/* write file and trigger a download */
XLSX.writeFile(new_wb, 'sheetjs.xlsx', {});
}
</script>
<script type="text/javascript">
/* eslint no-use-before-define:0 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

15
xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

22
xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

25011
xlsx.js

File diff suppressed because it is too large Load Diff

View File

@ -1,131 +0,0 @@
/*! xlsxspread.js (C) SheetJS LLC -- https://sheetjs.com/ */
/* eslint-env browser */
/*global XLSX */
/*exported stox, xtos */
/**
* Converts data from SheetJS to x-spreadsheet
*
* @param {Object} wb SheetJS workbook object
*
* @returns {Object[]} An x-spreadsheet data
*/
function stox(wb) {
var out = [];
wb.SheetNames.forEach(function (name) {
var o = { name: name, rows: {} };
var ws = wb.Sheets[name];
if(!ws || !ws["!ref"]) return;
var range = XLSX.utils.decode_range(ws['!ref']);
// sheet_to_json will lost empty row and col at begin as default
range.s = { r: 0, c: 0 };
var aoa = XLSX.utils.sheet_to_json(ws, {
raw: false,
header: 1,
range: range
});
aoa.forEach(function (r, i) {
var cells = {};
r.forEach(function (c, j) {
cells[j] = { text: c };
var cellRef = XLSX.utils.encode_cell({ r: i, c: j });
if ( ws[cellRef] != null && ws[cellRef].f != null) {
cells[j].text = "=" + ws[cellRef].f;
}
});
o.rows[i] = { cells: cells };
});
o.merges = [];
(ws["!merges"]||[]).forEach(function (merge, i) {
//Needed to support merged cells with empty content
if (o.rows[merge.s.r] == null) {
o.rows[merge.s.r] = { cells: {} };
}
if (o.rows[merge.s.r].cells[merge.s.c] == null) {
o.rows[merge.s.r].cells[merge.s.c] = {};
}
o.rows[merge.s.r].cells[merge.s.c].merge = [
merge.e.r - merge.s.r,
merge.e.c - merge.s.c
];
o.merges[i] = XLSX.utils.encode_range(merge);
});
out.push(o);
});
return out;
}
/**
* Converts data from x-spreadsheet to SheetJS
*
* @param {Object[]} sdata An x-spreadsheet data object
*
* @returns {Object} A SheetJS workbook object
*/
function xtos(sdata) {
var out = XLSX.utils.book_new();
sdata.forEach(function (xws) {
var ws = {};
var rowobj = xws.rows;
var minCoord = { r: 0, c: 0 }, maxCoord = { r: 0, c: 0 };
for (var ri = 0; ri < rowobj.len; ++ri) {
var row = rowobj[ri];
if (!row) continue;
Object.keys(row.cells).forEach(function (k) {
var idx = +k;
if (isNaN(idx)) return;
var lastRef = XLSX.utils.encode_cell({ r: ri, c: idx });
if (ri > maxCoord.r) maxCoord.r = ri;
if (idx > maxCoord.c) maxCoord.c = idx;
var cellText = row.cells[k].text, type = "s";
if (!cellText) {
cellText = "";
type = "z";
} else if (!isNaN(Number(cellText))) {
cellText = Number(cellText);
type = "n";
} else if (cellText.toLowerCase() === "true" || cellText.toLowerCase() === "false") {
cellText = Boolean(cellText);
type = "b";
}
ws[lastRef] = { v: cellText, t: type };
if (type == "s" && cellText[0] == "=") {
ws[lastRef].f = cellText.slice(1);
}
if (row.cells[k].merge != null) {
if (ws["!merges"] == null) ws["!merges"] = [];
ws["!merges"].push({
s: { r: ri, c: idx },
e: {
r: ri + row.cells[k].merge[0],
c: idx + row.cells[k].merge[1]
}
});
}
});
}
ws["!ref"] = minCoord ? XLSX.utils.encode_range({
s: minCoord,
e: maxCoord
}) : "A1";
XLSX.utils.book_append_sheet(out, ws, xws.name);
});
return out;
}

View File

@ -1,12 +0,0 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
importScripts('shim.js');
importScripts('xlsx.full.min.js');
postMessage({t:"ready"});
onmessage = function (evt) {
var v;
try {
v = XLSX.read(evt.data.d, {type: evt.data.b, codepage: evt.data.c});
postMessage({t:"xlsx", d:JSON.stringify(v)});
} catch(e) { postMessage({t:"e",d:e.stack||e}); }
};