| 
									
										
										
										
											2013-04-13 13:56:25 +00:00
										 |  |  | <!DOCTYPE html> | 
					
						
							| 
									
										
										
										
											2016-12-31 08:20:45 +00:00
										 |  |  | <!-- xlsx.js (C) 2013-present  SheetJS http://sheetjs.com --> | 
					
						
							| 
									
										
										
										
											2014-02-17 21:33:50 +00:00
										 |  |  | <!-- vim: set ts=2: --> | 
					
						
							| 
									
										
										
										
											2013-11-12 16:29:53 +00:00
										 |  |  | <html> | 
					
						
							|  |  |  | <head> | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | <title>SheetJS Live Demo</title> | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | <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 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-03-02 06:47:41 +00:00
										 |  |  | #b64data{ | 
					
						
							|  |  |  | 	width:100%; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | a { text-decoration: none } | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | </style> | 
					
						
							| 
									
										
										
										
											2013-11-12 16:29:53 +00:00
										 |  |  | </head> | 
					
						
							|  |  |  | <body> | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | <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()"> | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | <option value="csv" selected> CSV</option> | 
					
						
							|  |  |  | <option value="json"> JSON</option> | 
					
						
							|  |  |  | <option value="form"> FORMULAE</option> | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | <option value="html"> HTML</option> | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | </select><br /> | 
					
						
							| 
									
										
										
										
											2017-03-05 00:56:31 +00:00
										 |  |  | <div id="drop">Drop a spreadsheet file here to see sheet data</div> | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | <input type="file" name="xlfile" id="xlf" /> ... or click here to select a file | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-02 06:47:41 +00:00
										 |  |  | <textarea id="b64data">... or paste a base64-encoding here</textarea> | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | <input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br /> | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | <b>Advanced Demo Options:</b> | 
					
						
							|  |  |  | Use Web Workers: (when available) <input type="checkbox" name="useworker" checked> | 
					
						
							|  |  |  | Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked> | 
					
						
							|  |  |  | </pre> | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | <pre id="out"></pre> | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | <div id="htmlout"></div> | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | <br /> | 
					
						
							| 
									
										
										
										
											2014-05-22 12:16:51 +00:00
										 |  |  | <!-- uncomment the next line here and in xlsxworker.js for encoding support --> | 
					
						
							| 
									
										
										
										
											2017-03-09 05:24:32 +00:00
										 |  |  | <script src="dist/cpexcel.js"></script> | 
					
						
							| 
									
										
										
										
											2014-06-05 07:06:20 +00:00
										 |  |  | <script src="shim.js"></script> | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | <script src="jszip.js"></script> | 
					
						
							|  |  |  | <script src="xlsx.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							| 
									
										
										
										
											2017-03-10 01:09:18 +00:00
										 |  |  | /*jshint browser:true */ | 
					
						
							| 
									
										
										
										
											2017-05-09 18:07:57 +00:00
										 |  |  | /* eslint-env browser */ | 
					
						
							| 
									
										
										
										
											2020-03-15 07:42:05 +00:00
										 |  |  | /*global Uint8Array */ | 
					
						
							| 
									
										
										
										
											2017-03-10 01:09:18 +00:00
										 |  |  | /*global XLSX */ | 
					
						
							| 
									
										
										
										
											2018-01-23 09:07:51 +00:00
										 |  |  | /* exported b64it, setfmt */ | 
					
						
							|  |  |  | /* eslint no-use-before-define:0 */ | 
					
						
							| 
									
										
										
										
											2015-04-02 20:32:22 +00:00
										 |  |  | var X = XLSX; | 
					
						
							|  |  |  | var XW = { | 
					
						
							|  |  |  | 	/* worker message */ | 
					
						
							|  |  |  | 	msg: 'xlsx', | 
					
						
							|  |  |  | 	/* worker scripts */ | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	worker: './xlsxworker.js' | 
					
						
							| 
									
										
										
										
											2015-04-02 20:32:22 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | var global_wb; | 
					
						
							| 
									
										
										
										
											2014-08-18 16:28:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | var process_wb = (function() { | 
					
						
							|  |  |  | 	var OUT = document.getElementById('out'); | 
					
						
							|  |  |  | 	var HTMLOUT = document.getElementById('htmlout'); | 
					
						
							| 
									
										
										
										
											2014-02-17 21:33:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	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; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 	})(); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	var to_json = function to_json(workbook) { | 
					
						
							|  |  |  | 		var result = {}; | 
					
						
							|  |  |  | 		workbook.SheetNames.forEach(function(sheetName) { | 
					
						
							| 
									
										
										
										
											2017-11-23 04:49:28 +00:00
										 |  |  | 			var roa = X.utils.sheet_to_json(workbook.Sheets[sheetName], {header:1}); | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 			if(roa.length) result[sheetName] = roa; | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		return JSON.stringify(result, 2, 2); | 
					
						
							| 
									
										
										
										
											2013-11-22 22:58:11 +00:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	var to_csv = function to_csv(workbook) { | 
					
						
							|  |  |  | 		var result = []; | 
					
						
							|  |  |  | 		workbook.SheetNames.forEach(function(sheetName) { | 
					
						
							|  |  |  | 			var csv = X.utils.sheet_to_csv(workbook.Sheets[sheetName]); | 
					
						
							|  |  |  | 			if(csv.length){ | 
					
						
							|  |  |  | 				result.push("SHEET: " + sheetName); | 
					
						
							|  |  |  | 				result.push(""); | 
					
						
							|  |  |  | 				result.push(csv); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		return result.join("\n"); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	var to_fmla = function to_fmla(workbook) { | 
					
						
							|  |  |  | 		var result = []; | 
					
						
							|  |  |  | 		workbook.SheetNames.forEach(function(sheetName) { | 
					
						
							|  |  |  | 			var formulae = X.utils.get_formulae(workbook.Sheets[sheetName]); | 
					
						
							|  |  |  | 			if(formulae.length){ | 
					
						
							|  |  |  | 				result.push("SHEET: " + sheetName); | 
					
						
							|  |  |  | 				result.push(""); | 
					
						
							|  |  |  | 				result.push(formulae.join("\n")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		return result.join("\n"); | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	var to_html = function to_html(workbook) { | 
					
						
							|  |  |  | 		HTMLOUT.innerHTML = ""; | 
					
						
							|  |  |  | 		workbook.SheetNames.forEach(function(sheetName) { | 
					
						
							| 
									
										
										
										
											2018-03-06 00:34:04 +00:00
										 |  |  | 			var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 			HTMLOUT.innerHTML += htmlstr; | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 		return ""; | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-05-06 14:54:42 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 		if(OUT.innerText === undefined) OUT.textContent = output; | 
					
						
							|  |  |  | 		else OUT.innerText = output; | 
					
						
							|  |  |  | 		if(typeof console !== 'undefined') console.log("output", new Date()); | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | })(); | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | var setfmt = window.setfmt = function setfmt() { if(global_wb) process_wb(global_wb); }; | 
					
						
							| 
									
										
										
										
											2013-03-02 06:47:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | var b64it = window.b64it = (function() { | 
					
						
							|  |  |  | 	var tarea = document.getElementById('b64data'); | 
					
						
							|  |  |  | 	return function b64it() { | 
					
						
							|  |  |  | 		if(typeof console !== 'undefined') console.log("onload", new Date()); | 
					
						
							|  |  |  | 		var wb = X.read(tarea.value, {type:'base64', WTF:false}); | 
					
						
							|  |  |  | 		process_wb(wb); | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | })(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var do_file = (function() { | 
					
						
							|  |  |  | 	var rABS = typeof FileReader !== "undefined" && (FileReader.prototype||{}).readAsBinaryString; | 
					
						
							|  |  |  | 	var domrabs = document.getElementsByName("userabs")[0]; | 
					
						
							|  |  |  | 	if(!rABS) domrabs.disabled = !(domrabs.checked = false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	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(XW.worker); | 
					
						
							|  |  |  | 		worker.onmessage = function(e) { | 
					
						
							|  |  |  | 			switch(e.data.t) { | 
					
						
							|  |  |  | 				case 'ready': break; | 
					
						
							|  |  |  | 				case 'e': console.error(e.data.d); break; | 
					
						
							|  |  |  | 				case XW.msg: cb(JSON.parse(e.data.d)); break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 		worker.postMessage({d:data,b:rABS?'binary':'array'}); | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2013-03-02 06:47:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	return function do_file(files) { | 
					
						
							|  |  |  | 		rABS = domrabs.checked; | 
					
						
							|  |  |  | 		use_worker = domwork.checked; | 
					
						
							|  |  |  | 		var f = files[0]; | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 		var reader = new FileReader(); | 
					
						
							|  |  |  | 		reader.onload = function(e) { | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 			if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker); | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 			var data = e.target.result; | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 			if(!rABS) data = new Uint8Array(data); | 
					
						
							|  |  |  | 			if(use_worker) xw(data, process_wb); | 
					
						
							|  |  |  | 			else process_wb(X.read(data, {type: rABS ? 'binary' : 'array'})); | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2014-01-23 06:20:19 +00:00
										 |  |  | 		if(rABS) reader.readAsBinaryString(f); | 
					
						
							|  |  |  | 		else reader.readAsArrayBuffer(f); | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	}; | 
					
						
							|  |  |  | })(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | (function() { | 
					
						
							|  |  |  | 	var drop = document.getElementById('drop'); | 
					
						
							|  |  |  | 	if(!drop.addEventListener) return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function handleDrop(e) { | 
					
						
							|  |  |  | 		e.stopPropagation(); | 
					
						
							|  |  |  | 		e.preventDefault(); | 
					
						
							|  |  |  | 		do_file(e.dataTransfer.files); | 
					
						
							| 
									
										
										
										
											2013-02-18 03:40:27 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | 	function handleDragover(e) { | 
					
						
							|  |  |  | 		e.stopPropagation(); | 
					
						
							|  |  |  | 		e.preventDefault(); | 
					
						
							|  |  |  | 		e.dataTransfer.dropEffect = 'copy'; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-05 22:01:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 13:56:25 +00:00
										 |  |  | 	drop.addEventListener('dragenter', handleDragover, false); | 
					
						
							| 
									
										
										
										
											2013-03-05 22:01:01 +00:00
										 |  |  | 	drop.addEventListener('dragover', handleDragover, false); | 
					
						
							|  |  |  | 	drop.addEventListener('drop', handleDrop, false); | 
					
						
							| 
									
										
										
										
											2017-08-19 23:06:34 +00:00
										 |  |  | })(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | (function() { | 
					
						
							|  |  |  | 	var xlf = document.getElementById('xlf'); | 
					
						
							|  |  |  | 	if(!xlf.addEventListener) return; | 
					
						
							|  |  |  | 	function handleFile(e) { do_file(e.target.files); } | 
					
						
							|  |  |  | 	xlf.addEventListener('change', handleFile, false); | 
					
						
							|  |  |  | })(); | 
					
						
							| 
									
										
										
										
											2017-04-20 03:24:48 +00:00
										 |  |  | 	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> | 
					
						
							| 
									
										
										
										
											2013-11-12 16:29:53 +00:00
										 |  |  | </body> | 
					
						
							|  |  |  | </html> |