/* note: browser DOM element cannot see mso- style attrs, must parse */ var HTML_ = (function() { function html_to_sheet(str/*:string*/, _opts)/*:Workbook*/ { var opts = _opts || {}; if(DENSE != null && opts.dense == null) opts.dense = DENSE; var ws/*:Worksheet*/ = opts.dense ? ([]/*:any*/) : ({}/*:any*/); var mtch/*:any*/ = str.match(/
")) > -1) m = m.slice(cc+1); while(m.indexOf(">") > -1) m = m.slice(0, m.lastIndexOf("<")); var tag = parsexmltag(cell.slice(0, cell.indexOf(">"))); CS = tag.colspan ? +tag.colspan : 1; if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}}); /* TODO: generate stub cells */ if(!m.length) { C += CS; continue; } m = unescapexml(m).replace(/[\r\n]/g,""); 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(opts.dense) { if(!ws[R]) ws[R] = []; if(!m.length){} else if(opts.raw) ws[R][C] = {t:'s', v:m}; else if(m === 'TRUE') ws[R][C] = {t:'b', v:true}; else if(m === 'FALSE') ws[R][C] = {t:'b', v:false}; else if(!isNaN(fuzzynum(m))) ws[R][C] = {t:'n', v:fuzzynum(m)}; else ws[R][C] = {t:'s', v:m}; } else { var coord/*:string*/ = encode_cell({r:R, c:C}); /* TODO: value parsing */ if(!m.length){} else if(opts.raw) ws[coord] = {t:'s', v:m}; else if(m === 'TRUE') ws[coord] = {t:'b', v:true}; else if(m === 'FALSE') ws[coord] = {t:'b', v:false}; else if(!isNaN(fuzzynum(m))) ws[coord] = {t:'n', v:fuzzynum(m)}; else ws[coord] = {t:'s', v:m}; } C += CS; } } ws['!ref'] = encode_range(range); return ws; } function html_to_book(str/*:string*/, opts)/*:Workbook*/ { return sheet_to_workbook(html_to_sheet(str, opts), opts); } function make_html_row(ws/*:Worksheet*/, r/*:Range*/, R/*:number*/, o/*:Sheet2HTMLOpts*/)/*:string*/ { var M = (ws['!merges'] ||[]); var oo = []; var nullcell = " | "; for(var C = r.s.c; C <= r.e.c; ++C) { var RS = 0, CS = 0; for(var j = 0; j < M.length; ++j) { if(M[j].s.r > R || M[j].s.c > C) continue; if(M[j].e.r < R || M[j].e.c < C) continue; if(M[j].s.r < R || M[j].s.c < C) { RS = -1; break; } RS = M[j].e.r - M[j].s.r + 1; CS = M[j].e.c - M[j].s.c + 1; break; } if(RS < 0) continue; var coord = encode_cell({r:R,c:C}); var cell = o.dense ? (ws[R]||[])[C] : ws[coord]; if(!cell || cell.v == null) { oo.push(nullcell); continue; } /* TODO: html entities */ var w = cell.h || escapexml(cell.w || (format_cell(cell), cell.w) || ""); var sp = {}; if(RS > 1) sp.rowspan = RS; if(CS > 1) sp.colspan = CS; if(o.editable) sp.contenteditable = "true"; sp.id = "sjs-" + coord; oo.push(writextag('td', w, sp)); } var preamble = " |