| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | var strs = {}; // shared strings
 | 
					
						
							|  |  |  | var _ssfopts = {}; // spreadsheet formatting options
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-27 21:35:15 +00:00
										 |  |  | RELS.WS = [ | 
					
						
							|  |  |  | 	"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", | 
					
						
							|  |  |  | 	"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet" | 
					
						
							|  |  |  | ]; | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-12 18:02:43 +00:00
										 |  |  | function get_sst_id(sst/*:SST*/, str/*:string*/)/*:number*/ { | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 	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; | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-28 22:03:03 +00:00
										 |  |  | function col_obj_w(C/*:number*/, col) { | 
					
						
							|  |  |  | 	var p = ({min:C+1,max:C+1}/*:any*/); | 
					
						
							|  |  |  | 	/* wch (chars), wpx (pixels) */ | 
					
						
							| 
									
										
										
										
											2017-04-28 07:28:03 +00:00
										 |  |  | 	var wch = -1; | 
					
						
							| 
									
										
										
										
											2017-03-28 22:03:03 +00:00
										 |  |  | 	if(col.MDW) MDW = col.MDW; | 
					
						
							|  |  |  | 	if(col.width != null) p.customWidth = 1; | 
					
						
							| 
									
										
										
										
											2017-04-28 07:28:03 +00:00
										 |  |  | 	else if(col.wpx != null) wch = px2char(col.wpx); | 
					
						
							|  |  |  | 	else if(col.wch != null) wch = col.wch; | 
					
						
							|  |  |  | 	if(wch > -1) { p.width = char2width(wch); p.customWidth = 1; } | 
					
						
							|  |  |  | 	else if(col.width != null) p.width = col.width; | 
					
						
							|  |  |  | 	if(col.hidden) p.hidden = true; | 
					
						
							| 
									
										
										
										
											2017-03-28 22:03:03 +00:00
										 |  |  | 	return p; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-13 18:21:22 +00:00
										 |  |  | function default_margins(margins/*:Margins*/, mode/*:?string*/) { | 
					
						
							| 
									
										
										
										
											2017-04-13 01:29:38 +00:00
										 |  |  | 	if(!margins) return; | 
					
						
							|  |  |  | 	var defs = [0.7, 0.7, 0.75, 0.75, 0.3, 0.3]; | 
					
						
							|  |  |  | 	if(mode == 'xlml') defs = [1, 1, 1, 1, 0.5, 0.5]; | 
					
						
							|  |  |  | 	if(margins.left   == null) margins.left   = defs[0]; | 
					
						
							|  |  |  | 	if(margins.right  == null) margins.right  = defs[1]; | 
					
						
							|  |  |  | 	if(margins.top    == null) margins.top    = defs[2]; | 
					
						
							|  |  |  | 	if(margins.bottom == null) margins.bottom = defs[3]; | 
					
						
							|  |  |  | 	if(margins.header == null) margins.header = defs[4]; | 
					
						
							|  |  |  | 	if(margins.footer == null) margins.footer = defs[5]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | function get_cell_style(styles, cell, opts) { | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	var z = opts.revssf[cell.z != null ? cell.z : "General"]; | 
					
						
							| 
									
										
										
										
											2017-05-09 18:07:57 +00:00
										 |  |  | 	var i = 0x3c, len = styles.length; | 
					
						
							|  |  |  | 	if(z == null && opts.ssf) { | 
					
						
							|  |  |  | 		for(; i < 0x188; ++i) if(opts.ssf[i] == null) { | 
					
						
							|  |  |  | 			SSF.load(cell.z, i); | 
					
						
							|  |  |  | 			opts.ssf[i] = cell.z; | 
					
						
							|  |  |  | 			opts.revssf[cell.z] = z = i; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for(i = 0; i != len; ++i) if(styles[i].numFmtId === z) return i; | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 	styles[len] = { | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | 		numFmtId:z, | 
					
						
							|  |  |  | 		fontId:0, | 
					
						
							|  |  |  | 		fillId:0, | 
					
						
							|  |  |  | 		borderId:0, | 
					
						
							|  |  |  | 		xfId:0, | 
					
						
							|  |  |  | 		applyNumberFormat:1 | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 	return len; | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-05 06:32:57 +00:00
										 |  |  | function safe_format(p, fmtid/*:number*/, fillid/*:?number*/, opts, themes, styles) { | 
					
						
							| 
									
										
										
										
											2017-03-15 08:19:02 +00:00
										 |  |  | 	if(p.t === 'z') return; | 
					
						
							| 
									
										
										
										
											2017-03-23 01:18:40 +00:00
										 |  |  | 	if(p.t === 'd' && typeof p.v === 'string') p.v = parseDate(p.v); | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | 	try { | 
					
						
							| 
									
										
										
										
											2017-04-21 22:02:02 +00:00
										 |  |  | 		if(opts.cellNF) p.z = SSF._table[fmtid]; | 
					
						
							|  |  |  | 	} catch(e) { if(opts.WTF) throw e; } | 
					
						
							|  |  |  | 	if(!opts || opts.cellText !== false) try { | 
					
						
							| 
									
										
										
										
											2014-10-26 05:26:18 +00:00
										 |  |  | 		if(p.t === 'e') p.w = p.w || BErr[p.v]; | 
					
						
							|  |  |  | 		else if(fmtid === 0) { | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 			if(p.t === 'n') { | 
					
						
							| 
									
										
										
										
											2017-07-27 20:07:51 +00:00
										 |  |  | 				if((p.v|0) === p.v) p.w = SSF._general_int(p.v); | 
					
						
							|  |  |  | 				else p.w = SSF._general_num(p.v); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-10-26 05:26:18 +00:00
										 |  |  | 			else if(p.t === 'd') { | 
					
						
							|  |  |  | 				var dd = datenum(p.v); | 
					
						
							| 
									
										
										
										
											2017-07-27 20:07:51 +00:00
										 |  |  | 				if((dd|0) === dd) p.w = SSF._general_int(dd); | 
					
						
							|  |  |  | 				else p.w = SSF._general_num(dd); | 
					
						
							| 
									
										
										
										
											2014-10-26 05:26:18 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 			else if(p.v === undefined) return ""; | 
					
						
							|  |  |  | 			else p.w = SSF._general(p.v,_ssfopts); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-10-26 05:26:18 +00:00
										 |  |  | 		else if(p.t === 'd') p.w = SSF.format(fmtid,datenum(p.v),_ssfopts); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 		else p.w = SSF.format(fmtid,p.v,_ssfopts); | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | 	} catch(e) { if(opts.WTF) throw e; } | 
					
						
							| 
									
										
										
										
											2017-08-05 06:32:57 +00:00
										 |  |  | 	if(!opts.cellStyles) return; | 
					
						
							|  |  |  | 	if(fillid != null) try { | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | 		p.s = styles.Fills[fillid]; | 
					
						
							| 
									
										
										
										
											2017-05-09 18:07:57 +00:00
										 |  |  | 		if (p.s.fgColor && p.s.fgColor.theme && !p.s.fgColor.rgb) { | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | 			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; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-05 06:32:57 +00:00
										 |  |  | 	} catch(e) { if(opts.WTF && styles.Fills) throw e; } | 
					
						
							| 
									
										
										
										
											2014-06-02 05:19:07 +00:00
										 |  |  | } |