forked from sheetjs/sheetjs
		
	
		
			
	
	
		
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			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>
							 | 
						||
| 
								 | 
							
								a { text-decoration: none }
							 | 
						||
| 
								 | 
							
								</style>
							 | 
						||
| 
								 | 
							
								</head>
							 | 
						||
| 
								 | 
							
								<body>
							 | 
						||
| 
								 | 
							
								<pre>
							 | 
						||
| 
								 | 
							
								<b><a href="http://sheetjs.com">SheetJS LocalStorage Demo</a></b>
							 | 
						||
| 
								 | 
							
								<pre id="data_">
							 | 
						||
| 
								 | 
							
								Original Data:
							 | 
						||
| 
								 | 
							
								</pre>
							 | 
						||
| 
								 | 
							
								<pre id="out">
							 | 
						||
| 
								 | 
							
								Output:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								</pre>
							 | 
						||
| 
								 | 
							
								<script src="xlsx.full.min.js"></script>
							 | 
						||
| 
								 | 
							
								<script src="ObjUtils.js"></script>
							 | 
						||
| 
								 | 
							
								<script src="https://unpkg.com/localforage/dist/localforage.min.js"></script>
							 | 
						||
| 
								 | 
							
								<script src="SheetJSForage.js"></script>
							 | 
						||
| 
								 | 
							
								<script>
							 | 
						||
| 
								 | 
							
								/* eslint-env browser */
							 | 
						||
| 
								 | 
							
								/*global XLSX, localforage */
							 | 
						||
| 
								 | 
							
								var data = {
							 | 
						||
| 
								 | 
							
								  "title": "SheetDB",
							 | 
						||
| 
								 | 
							
								  "metadata": {
							 | 
						||
| 
								 | 
							
								    "author": "SheetJS",
							 | 
						||
| 
								 | 
							
								    "code": 7262
							 | 
						||
| 
								 | 
							
								  },
							 | 
						||
| 
								 | 
							
								  "data": [
							 | 
						||
| 
								 | 
							
								    { "Name": "Barack Obama", "Index": 44 },
							 | 
						||
| 
								 | 
							
								    { "Name": "Donald Trump", "Index": 45 },
							 | 
						||
| 
								 | 
							
								  ]
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								document.getElementById("data_").innerText += JSON.stringify(data, 2, 2);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								localforage.setDriver(localforage.INDEXEDDB);
							 | 
						||
| 
								 | 
							
								(async function() {
							 | 
						||
| 
								 | 
							
								  await localforage.clear();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  await localforage.load(data);
							 | 
						||
| 
								 | 
							
								  var wb = await localforage.dump();
							 | 
						||
| 
								 | 
							
								  console.log(wb);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  var OUT = document.getElementById("out");
							 | 
						||
| 
								 | 
							
								  wb.SheetNames.forEach(function(n, i) {
							 | 
						||
| 
								 | 
							
								    OUT.innerText += "Sheet " + i + " (" + n + ")\n";
							 | 
						||
| 
								 | 
							
								    OUT.innerText += XLSX.utils.sheet_to_csv(wb.Sheets[n]);
							 | 
						||
| 
								 | 
							
								    OUT.innerText += "\n";
							 | 
						||
| 
								 | 
							
								  });
							 | 
						||
| 
								 | 
							
								})();
							 | 
						||
| 
								 | 
							
								</script>
							 | 
						||
| 
								 | 
							
								</body>
							 | 
						||
| 
								 | 
							
								</html>
							 |