disambiguate duplicate header names

closes #194 h/t @patricklam

note: @sheetjsdev authored commit, original PR date/author used
This commit is contained in:
Patrick Lam 2015-03-28 22:12:16 -04:00 committed by SheetJS
parent d4829476f7
commit b0a72c8b0e
4 changed files with 18 additions and 9 deletions

@ -922,7 +922,7 @@ function stringify_formula(formula, range, cell, supbooks, opts) {
break;
/* 2.5.198.29 */
case 'PtgAreaErr': stack.push("#REF!");
case 'PtgAreaErr': stack.push("#REF!"); break;
/* 2.5.198.72 TODO */
case 'PtgMemFunc': break;

@ -73,7 +73,7 @@ function format_cell(cell/*:Cell*/, v/*:any*/) {
}
function sheet_to_json(sheet/*:Worksheet*/, opts/*:?Sheet2JSONOpts*/){
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v;
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v, vv;
var o = opts != null ? opts : {};
var raw = o.raw;
if(sheet == null || sheet["!ref"] == null) return [];
@ -100,7 +100,10 @@ function sheet_to_json(sheet/*:Worksheet*/, opts/*:?Sheet2JSONOpts*/){
case 3: hdr[C] = o.header[C - r.s.c]; break;
default:
if(val === undefined) continue;
hdr[C] = format_cell(val);
vv = v = format_cell(val);
var counter = 0;
for(var CC = 0; CC < hdr.length; ++CC) if(hdr[CC] == vv) vv = v + "_" + (++counter);
hdr[C] = vv;
}
}

@ -6734,7 +6734,7 @@ function stringify_formula(formula, range, cell, supbooks, opts) {
break;
/* 2.5.198.29 */
case 'PtgAreaErr': stack.push("#REF!");
case 'PtgAreaErr': stack.push("#REF!"); break;
/* 2.5.198.72 TODO */
case 'PtgMemFunc': break;
@ -13342,7 +13342,7 @@ function format_cell(cell/*:Cell*/, v/*:any*/) {
}
function sheet_to_json(sheet/*:Worksheet*/, opts/*:?Sheet2JSONOpts*/){
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v;
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v, vv;
var o = opts != null ? opts : {};
var raw = o.raw;
if(sheet == null || sheet["!ref"] == null) return [];
@ -13369,7 +13369,10 @@ function sheet_to_json(sheet/*:Worksheet*/, opts/*:?Sheet2JSONOpts*/){
case 3: hdr[C] = o.header[C - r.s.c]; break;
default:
if(val === undefined) continue;
hdr[C] = format_cell(val);
vv = v = format_cell(val);
var counter = 0;
for(var CC = 0; CC < hdr.length; ++CC) if(hdr[CC] == vv) vv = v + "_" + (++counter);
hdr[C] = vv;
}
}

@ -6692,7 +6692,7 @@ function stringify_formula(formula, range, cell, supbooks, opts) {
break;
/* 2.5.198.29 */
case 'PtgAreaErr': stack.push("#REF!");
case 'PtgAreaErr': stack.push("#REF!"); break;
/* 2.5.198.72 TODO */
case 'PtgMemFunc': break;
@ -13291,7 +13291,7 @@ function format_cell(cell, v) {
}
function sheet_to_json(sheet, opts){
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v;
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v, vv;
var o = opts != null ? opts : {};
var raw = o.raw;
if(sheet == null || sheet["!ref"] == null) return [];
@ -13318,7 +13318,10 @@ function sheet_to_json(sheet, opts){
case 3: hdr[C] = o.header[C - r.s.c]; break;
default:
if(val === undefined) continue;
hdr[C] = format_cell(val);
vv = v = format_cell(val);
var counter = 0;
for(var CC = 0; CC < hdr.length; ++CC) if(hdr[CC] == vv) vv = v + "_" + (++counter);
hdr[C] = vv;
}
}