deno.land / x / sheetjs@v0.18.3 / index.html

<!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 } </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> </select><br /> <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> <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> </pre> <pre id="out"></pre> <div id="htmlout"></div> <br /> <!-- uncomment the next line here and in xlsxworker.js for encoding support --> <script src="dist/cpexcel.js"></script> <script src="shim.js"></script> <script src="xlsx.js"></script> <script> /*jshint browser:true */ /* eslint-env browser */ /*global Uint8Array */ /*global XLSX */ /* exported b64it, setfmt */ /* 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 ""; }; 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; default: 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 setfmt = window.setfmt = function setfmt() { if(global_wb) process_wb(global_wb); }; 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); }; })(); var do_file = (function() { var use_worker = typeof Worker !== 'undefined'; var domwork = document.getElementsByName("useworker")[0]; if(!use_worker) domwork.disabled = !(domwork.checked = false); 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'}); }; return function do_file(files) { use_worker = domwork.checked; var f = files[0]; var reader = new FileReader(); 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'})); }; 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 _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>
sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
GitHub RepositorySheetJS/sheetjs
GitHub Stars
31798

Version Info

Tagged at
9 months ago