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 |
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
 | |
| function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
 | |
| 	for(var i = 0; i != dirComments.length; ++i) {
 | |
| 		var canonicalpath=dirComments[i];
 | |
| 		var comments=parse_cmnt(getzipdata(zip, canonicalpath.replace(/^\//,''), true), canonicalpath, opts);
 | |
| 		if(!comments || !comments.length) continue;
 | |
| 		// find the sheets targeted by these comments
 | |
| 		var sheetNames = keys(sheets);
 | |
| 		for(var j = 0; j != sheetNames.length; ++j) {
 | |
| 			var sheetName = sheetNames[j];
 | |
| 			var rels = sheetRels[sheetName];
 | |
| 			if(rels) {
 | |
| 				var rel = rels[canonicalpath];
 | |
| 				if(rel) insertCommentsIntoSheet(sheetName, sheets[sheetName], comments);
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| function insertCommentsIntoSheet(sheetName, sheet, comments) {
 | |
| 	comments.forEach(function(comment) {
 | |
| 		var cell = sheet[comment.ref];
 | |
| 		if (!cell) {
 | |
| 			cell = {};
 | |
| 			sheet[comment.ref] = cell;
 | |
| 			var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
 | |
| 			var thisCell = decode_cell(comment.ref);
 | |
| 			if(range.s.r > thisCell.r) range.s.r = thisCell.r;
 | |
| 			if(range.e.r < thisCell.r) range.e.r = thisCell.r;
 | |
| 			if(range.s.c > thisCell.c) range.s.c = thisCell.c;
 | |
| 			if(range.e.c < thisCell.c) range.e.c = thisCell.c;
 | |
| 			var encoded = encode_range(range);
 | |
| 			if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
 | |
| 		}
 | |
| 
 | |
| 		if (!cell.c) cell.c = [];
 | |
| 		var o = ({a: comment.author, t: comment.t, r: comment.r}/*:any*/);
 | |
| 		if(comment.h) o.h = comment.h;
 | |
| 		cell.c.push(o);
 | |
| 	});
 | |
| }
 | |
| 
 |