forked from sheetjs/sheetjs
		
	Added round-trip test for styles
This commit is contained in:
		
							parent
							
								
									995f5e89bf
								
							
						
					
					
						commit
						9102c8214d
					
				| @ -12,11 +12,9 @@ function get_cell_style(styles, cell, opts) { | ||||
|   if (typeof style_builder != 'undefined') { | ||||
|     if (/^\d+$/.exec(cell.s)) { return cell.s}  // if its already an integer index, let it be
 | ||||
|     if (cell.s && (cell.s == +cell.s)) { return cell.s}  // if its already an integer index, let it be
 | ||||
|     if (!cell.s) cell.s = {} | ||||
|     if (cell.z) cell.s.numFmt = cell.z; | ||||
|     cell.s = style_builder.addStyle(cell.s); | ||||
| 
 | ||||
|     return cell.s; | ||||
|     var s = cell.s || {}; | ||||
|     if (cell.z) s.numFmt = cell.z; | ||||
|     return style_builder.addStyle(s); | ||||
|   } | ||||
|   else { | ||||
|     var z = opts.revssf[cell.z != null ? cell.z : "General"]; | ||||
|  | ||||
| @ -250,7 +250,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess) { | ||||
|             fmtid = fillid = 0; | ||||
|             if(do_format && tag.s !== undefined) { | ||||
|               cf = styles.CellXf[tag.s]; | ||||
|               if (opts.cellStyles) p.s = get_cell_style_csf(cf) | ||||
|               if (opts.cellStyles) { | ||||
|                 p.s = get_cell_style_csf(cf) | ||||
|               } | ||||
|               if(cf != null) { | ||||
|                 if(cf.numFmtId != null) fmtid = cf.numFmtId; | ||||
|                 if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId; | ||||
|  | ||||
| @ -244,7 +244,7 @@ if ((typeof 'module' != 'undefined'  && typeof require != 'undefined') || (typeo | ||||
|         return count - 1; | ||||
|       }, | ||||
| 
 | ||||
|       _addNumFmt: function (numFmt) { | ||||
|         _addNumFmt: function (numFmt) { | ||||
|         if (!numFmt) { return 0; } | ||||
| 
 | ||||
|         if (typeof numFmt == 'string') { | ||||
| @ -257,6 +257,12 @@ if ((typeof 'module' != 'undefined'  && typeof require != 'undefined') || (typeo | ||||
|         if (/^[0-9]+$/.exec(numFmt)) { | ||||
|           return numFmt; // we're matching an integer against some known code
 | ||||
|         } | ||||
|         numFmt = numFmt | ||||
|             .replace(/&/g, '&') | ||||
|             .replace(/</g, '<') | ||||
|             .replace(/>/g, '>') | ||||
|             .replace(/"/g, '"') | ||||
|             .replace(/'/g, '''); | ||||
| 
 | ||||
| 
 | ||||
|         var $numFmt = XmlNode('numFmt') | ||||
|  | ||||
							
								
								
									
										1627
									
								
								test-style.js
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1627
									
								
								test-style.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										20
									
								
								xlsx.js
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										20
									
								
								xlsx.js
									
									
									
									
									
								
							| @ -2870,11 +2870,9 @@ function get_cell_style(styles, cell, opts) { | ||||
|   if (typeof style_builder != 'undefined') { | ||||
|     if (/^\d+$/.exec(cell.s)) { return cell.s}  // if its already an integer index, let it be
 | ||||
|     if (cell.s && (cell.s == +cell.s)) { return cell.s}  // if its already an integer index, let it be
 | ||||
|     if (!cell.s) cell.s = {} | ||||
|     if (cell.z) cell.s.numFmt = cell.z; | ||||
|     cell.s = style_builder.addStyle(cell.s); | ||||
| 
 | ||||
|     return cell.s; | ||||
|     var s = cell.s || {}; | ||||
|     if (cell.z) s.numFmt = cell.z; | ||||
|     return style_builder.addStyle(s); | ||||
|   } | ||||
|   else { | ||||
|     var z = opts.revssf[cell.z != null ? cell.z : "General"]; | ||||
| @ -3189,7 +3187,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess) { | ||||
|             fmtid = fillid = 0; | ||||
|             if(do_format && tag.s !== undefined) { | ||||
|               cf = styles.CellXf[tag.s]; | ||||
|               if (opts.cellStyles) p.s = get_cell_style_csf(cf) | ||||
|               if (opts.cellStyles) { | ||||
|                 p.s = get_cell_style_csf(cf) | ||||
|               } | ||||
|               if(cf != null) { | ||||
|                 if(cf.numFmtId != null) fmtid = cf.numFmtId; | ||||
|                 if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId; | ||||
| @ -5836,7 +5836,7 @@ if ((typeof 'module' != 'undefined'  && typeof require != 'undefined') || (typeo | ||||
|         return count - 1; | ||||
|       }, | ||||
| 
 | ||||
|       _addNumFmt: function (numFmt) { | ||||
|         _addNumFmt: function (numFmt) { | ||||
|         if (!numFmt) { return 0; } | ||||
| 
 | ||||
|         if (typeof numFmt == 'string') { | ||||
| @ -5849,6 +5849,12 @@ if ((typeof 'module' != 'undefined'  && typeof require != 'undefined') || (typeo | ||||
|         if (/^[0-9]+$/.exec(numFmt)) { | ||||
|           return numFmt; // we're matching an integer against some known code
 | ||||
|         } | ||||
|         numFmt = numFmt | ||||
|             .replace(/&/g, '&') | ||||
|             .replace(/</g, '<') | ||||
|             .replace(/>/g, '>') | ||||
|             .replace(/"/g, '"') | ||||
|             .replace(/'/g, '''); | ||||
| 
 | ||||
| 
 | ||||
|         var $numFmt = XmlNode('numFmt') | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user