| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | <!DOCTYPE html> | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | <!-- xlsx.js (C) 2013-2014 SheetJS http://sheetjs.com --> | 
					
						
							|  |  |  | <!-- vim: set ts=2: --> | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | <html> | 
					
						
							|  |  |  | <head> | 
					
						
							|  |  |  | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | 
					
						
							|  |  |  | <title>JS-XLSX AJAX Live Demo</title> | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +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 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #b64data{ | 
					
						
							|  |  |  | 	width:100%; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | </style> | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | </head> | 
					
						
							|  |  |  | <body> | 
					
						
							|  |  |  | <b>JS-XLSX (XLSX/XLSB/XLSM) AJAX Live Demo</b><br /> | 
					
						
							|  |  |  | <a href="https://github.com/SheetJS/js-xlsx">Github Repo</a><br /> | 
					
						
							|  |  |  | <a href="https://github.com/SheetJS/js-xlsx/issues">Issues?  Something look weird?  Click here and report an issue</a><br /> | 
					
						
							|  |  |  | <br/><div id="fileurl"></div> | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | <pre id="out"></pre> | 
					
						
							|  |  |  | <br /> | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | <!-- uncomment the next line here for encoding support --> | 
					
						
							|  |  |  | <!--<script src="dist/cpexcel.js"></script>--> | 
					
						
							| 
									
										
										
										
											2014-07-28 17:45:23 +00:00
										 |  |  | <script src="iemagic.js"></script> | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | <script src="shim.js"></script> | 
					
						
							|  |  |  | <script src="jszip.js"></script> | 
					
						
							|  |  |  | <script src="xlsx.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | function to_csv(workbook) { | 
					
						
							|  |  |  | 	var result = []; | 
					
						
							|  |  |  | 	workbook.SheetNames.forEach(function(sheetName) { | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | 		var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]); | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | 		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; | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | 	if(typeof console !== 'undefined') console.log("output", new Date()); | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var url = "test_files/formula_stress_test_ajax.xlsx"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | 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"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | document.getElementById('fileurl').innerHTML = '<a href="' + url + '">Download file</a>'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | oReq.open("GET", url, true); | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if(typeof Uint8Array !== 'undefined') { | 
					
						
							|  |  |  | 	oReq.responseType = "arraybuffer"; | 
					
						
							|  |  |  | 	oReq.onload = function(e) { | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | 		if(typeof console !== 'undefined') console.log("onload", new Date()); | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | 		var arraybuffer = oReq.response; | 
					
						
							|  |  |  | 		var data = new Uint8Array(arraybuffer); | 
					
						
							|  |  |  | 		var arr = new Array(); | 
					
						
							|  |  |  | 		for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]); | 
					
						
							|  |  |  | 		var wb = XLSX.read(arr.join(""), {type:"binary"}); | 
					
						
							|  |  |  | 		process_wb(wb); | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | } else { | 
					
						
							| 
									
										
										
										
											2014-07-28 17:45:23 +00:00
										 |  |  | 	oReq.setRequestHeader("Accept-Charset", "x-user-defined");	 | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | 	oReq.onreadystatechange = function() { if(oReq.readyState == 4 && oReq.status == 200) { | 
					
						
							| 
									
										
										
										
											2014-07-28 17:45:23 +00:00
										 |  |  | 		var ff = convertResponseBodyToText(oReq.responseBody); | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | 		if(typeof console !== 'undefined') console.log("onload", new Date()); | 
					
						
							| 
									
										
										
										
											2014-07-28 17:45:23 +00:00
										 |  |  | 		var wb = XLSX.read(ff, {type:"binary"}); | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | 		process_wb(wb); | 
					
						
							|  |  |  | 	} }; | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-07-22 17:56:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 15:26:21 +00:00
										 |  |  | 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> | 
					
						
							| 
									
										
										
										
											2014-07-31 01:36:45 +00:00
										 |  |  | </body> | 
					
						
							|  |  |  | </html> |