forked from sheetjs/sheetjs
		
	- eliminated functional constructs in hot functions - format try-catch block extracted into new function - cpexcel + codepage updated to 1.2.0 - more efficient (and correct) clean implementation of RGB/HSL/tint algorithms - xlsx binary --all option enables every extra formatting and saving option - column widths parsed and saved (requires cellStyles:true)
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.4 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, str) {
 | |
| 	for(var i = 0; i != sst.length; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
 | |
| 	sst[sst.length] = {t:str}; sst.Count ++; sst.Unique ++; return sst.length-1;
 | |
| }
 | |
| 
 | |
| function get_cell_style(styles, cell, opts) {
 | |
| 	var z = opts.revssf[cell.z||"General"];
 | |
| 	for(var i = 0; i != styles.length; ++i) if(styles[i].numFmtId === z) return i;
 | |
| 	styles[styles.length] = {
 | |
| 		numFmtId:z,
 | |
| 		fontId:0,
 | |
| 		fillId:0,
 | |
| 		borderId:0,
 | |
| 		xfId:0,
 | |
| 		applyNumberFormat:1
 | |
| 	};
 | |
| 	return styles.length-1;
 | |
| }
 | |
| 
 | |
| function safe_format(p, fmtid, fillid, opts) {
 | |
| 	try {
 | |
| 		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; }
 | |
| }
 |