forked from sheetjs/sheetjs
		
	- basic support for parsing BIFF2-4 - basic support for writing BIFF2 - cleaned up some bad substr uses for IE6 compatibility - added flow type annotations for xlsx.flow.js - added numerous null guards (fixes #255 h/t @martinheidegger) - README cleanup (fixes #539 h/t @oliversalzburg) - pin jszip to local version (closes #408 h/t @limouri) bower issues: | id | author | comment | |-----:|:------------------|:------------------------------------------| | #254 | @kkirsche | fixes #254 by removing version from json | | #165 | @vincentcialdella | fixes #165 by changing default script | | #180 | @owencraig | fixes #180 by using xlsx.core.min.js | format issues: | id | author | comment | |-----:|:------------------|:------------------------------------------| | #271 | @morstaine | fixes #271 by reworking related parse fns | | #504 | @JanSchuermannPH | fixes #504 detect FullPaths h/t @Mithgol | | #508 | @basma-emad | fixes #508 offending file used `x:` NS |
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| var strs = {}; // shared strings
 | |
| var _ssfopts = {}; // spreadsheet formatting options
 | |
| 
 | |
| RELS.WS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
 | |
| 
 | |
| function get_sst_id(sst/*:SST*/, str)/*:number*/ {
 | |
| 	for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
 | |
| 	sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
 | |
| }
 | |
| 
 | |
| function get_cell_style(styles, cell, opts) {
 | |
| 	var z = opts.revssf[cell.z != null ? cell.z : "General"];
 | |
| 	for(var i = 0, len = styles.length; i != len; ++i) if(styles[i].numFmtId === z) return i;
 | |
| 	styles[len] = {
 | |
| 		numFmtId:z,
 | |
| 		fontId:0,
 | |
| 		fillId:0,
 | |
| 		borderId:0,
 | |
| 		xfId:0,
 | |
| 		applyNumberFormat:1
 | |
| 	};
 | |
| 	return len;
 | |
| }
 | |
| 
 | |
| function safe_format(p, fmtid, fillid, opts) {
 | |
| 	try {
 | |
| 		if(p.t === 'e') p.w = p.w || BErr[p.v];
 | |
| 		else if(fmtid === 0) {
 | |
| 			if(p.t === 'n') {
 | |
| 				if((p.v|0) === p.v) p.w = SSF._general_int(p.v,_ssfopts);
 | |
| 				else p.w = SSF._general_num(p.v,_ssfopts);
 | |
| 			}
 | |
| 			else if(p.t === 'd') {
 | |
| 				var dd = datenum(p.v);
 | |
| 				if((dd|0) === dd) p.w = SSF._general_int(dd,_ssfopts);
 | |
| 				else p.w = SSF._general_num(dd,_ssfopts);
 | |
| 			}
 | |
| 			else if(p.v === undefined) return "";
 | |
| 			else p.w = SSF._general(p.v,_ssfopts);
 | |
| 		}
 | |
| 		else if(p.t === 'd') p.w = SSF.format(fmtid,datenum(p.v),_ssfopts);
 | |
| 		else p.w = SSF.format(fmtid,p.v,_ssfopts);
 | |
| 		if(opts.cellNF) p.z = SSF._table[fmtid];
 | |
| 	} catch(e) { if(opts.WTF) throw e; }
 | |
| 	if(fillid) try {
 | |
| 		p.s = styles.Fills[fillid];
 | |
| 		if (p.s.fgColor && p.s.fgColor.theme) {
 | |
| 			p.s.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p.s.fgColor.theme].rgb, p.s.fgColor.tint || 0);
 | |
| 			if(opts.WTF) p.s.fgColor.raw_rgb = themes.themeElements.clrScheme[p.s.fgColor.theme].rgb;
 | |
| 		}
 | |
| 		if (p.s.bgColor && p.s.bgColor.theme) {
 | |
| 			p.s.bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p.s.bgColor.theme].rgb, p.s.bgColor.tint || 0);
 | |
| 			if(opts.WTF) p.s.bgColor.raw_rgb = themes.themeElements.clrScheme[p.s.bgColor.theme].rgb;
 | |
| 		}
 | |
| 	} catch(e) { if(opts.WTF) throw e; }
 | |
| }
 |