forked from sheetjs/sheetjs
		
	- README and example cleanup - basic XLSB and ODS write support - flow typecheck for ODS file Note: xlsx.js flow fails: https://github.com/facebook/flow/issues/380 - exposed jszip compression (fixes #220, closes #284) README issues: | id | author | comment | |-----:|:---------------|:---------------------------------------------| | #202 | @sao93859 | closes #202 | | #211 | @alexanderchan | closes #211 corrected examples | | #327 | @cskaandorp | changed saveAs example to match write tests | | #424 | @dskrvk | added note about s2roa h/t @LeonardoPatignio | | #496 | @jimmywarting | closes #496 adapted rABS examples with rAAS | ODS file format issues: | id | author | comment | |-----:|:---------------|:---------------------------------------------| | #148 | @user4815162342| closes #148 h/t @ziacik | | #166 | @paulproteus | closes #166 rudimentary ODS write support | | #177 | @ziacik | closes #177 | | #179 | @ziacik | closes #179 use JSON when available | | #317 | @ziacik | closes #317 | | #328 | @think01 | closes #328 | | #383 | @mdamt | closes #383 duplicate cells should be copied | | #430 | @RB-Lab | closes #430 | | #546 | @lgodard | closes #546 thanks to other changes |
		
			
				
	
	
		
			30 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* Part 3 Section 4 Manifest File */
 | |
| var CT_ODS = "application/vnd.oasis.opendocument.spreadsheet";
 | |
| function parse_manifest(d, opts) {
 | |
| 	var str = xlml_normalize(d);
 | |
| 	var Rn;
 | |
| 	var FEtag;
 | |
| 	while((Rn = xlmlregex.exec(str))) switch(Rn[3]) {
 | |
| 		case 'manifest': break; // 4.2 <manifest:manifest>
 | |
| 		case 'file-entry': // 4.3 <manifest:file-entry>
 | |
| 			FEtag = parsexmltag(Rn[0], false);
 | |
| 			if(FEtag.path == '/' && FEtag.type !== CT_ODS) throw new Error("This OpenDocument is not a spreadsheet");
 | |
| 			break;
 | |
| 		case 'encryption-data': // 4.4 <manifest:encryption-data>
 | |
| 		case 'algorithm': // 4.5 <manifest:algorithm>
 | |
| 		case 'start-key-generation': // 4.6 <manifest:start-key-generation>
 | |
| 		case 'key-derivation': // 4.7 <manifest:key-derivation>
 | |
| 			throw new Error("Unsupported ODS Encryption");
 | |
| 		default: if(opts && opts.WTF) throw Rn;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| function write_manifest(manifest/*:Array<Array<string> >*/, opts)/*:string*/ {
 | |
| 	var o = [XML_HEADER];
 | |
| 	o.push('<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">\n');
 | |
| 	o.push('  <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.spreadsheet"/>\n');
 | |
| 	for(var i = 0; i < manifest.length; ++i) o.push('  <manifest:file-entry manifest:full-path="' + manifest[i][0] + '" manifest:media-type="' + manifest[i][1] + '"/>\n');
 | |
| 	o.push('</manifest:manifest>');
 | |
| 	return o.join("");
 | |
| }
 |