forked from sheetjs/sheetjs
HTML Parsing fix misaligned cells (fixes #1621)
This commit is contained in:
parent
b738e5d3f1
commit
b3793e2ea7
@ -38,7 +38,7 @@ var HTML_ = (function() {
|
||||
m = htmldecode(m);
|
||||
if(range.s.r > R) range.s.r = R; if(range.e.r < R) range.e.r = R;
|
||||
if(range.s.c > C) range.s.c = C; if(range.e.c < C) range.e.c = C;
|
||||
if(!m.length) continue;
|
||||
if(!m.length) { C += CS; continue; }
|
||||
var o/*:Cell*/ = {t:'s', v:m};
|
||||
if(opts.raw || !m.trim().length || _t == 's'){}
|
||||
else if(m === 'TRUE') o = {t:'b', v:true};
|
||||
|
14
test.js
14
test.js
@ -2286,6 +2286,20 @@ describe('HTML', function() {
|
||||
assert.equal(X.utils.sheet_to_csv(ws), "A,B\n1,2\n3,4\n4,6");
|
||||
});
|
||||
});
|
||||
describe('empty cell containing html element should increment cell index', function() {
|
||||
var html = "<table><tr><td>abc</td><td><b> </b></td><td>def</td></tr></table>";
|
||||
var expectedCellCount = 3;
|
||||
it('HTML string', function() {
|
||||
var ws = X.read(html, {type:'string'}).Sheets.Sheet1;
|
||||
var range = X.utils.decode_range(ws['!ref']);
|
||||
assert.equal(range.e.c,expectedCellCount - 1);
|
||||
});
|
||||
if(domtest) it('DOM', function() {
|
||||
var ws = X.utils.table_to_sheet(get_dom_element(html));
|
||||
var range = X.utils.decode_range(ws['!ref']);
|
||||
assert.equal(range.e.c, expectedCellCount - 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('js -> file -> js', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user