Based on the previous essay, the new requirement needs to be re-exported to the table above with a row header row
1 functionparse_dom_table_addtitle (table, _opts, title) {2 varopts = _opts | | {};3 varOSS = Opts.defaultcellstyle | | {};/*cell style*/4 if(Dense! =NULL) Opts.dense =dense;5 varWS = Opts.dense? ([]) : ({});6 varrows = Table.getelementsbytagname (' tr ');7 varSheetrows = math.min (opts.sheetrows | | 10000000, rows.length);8 varRange = {s: {r:0, c:0}, E: {r:sheetrows+1, c:0 } };9 varmerges = [], Midx = 0;Ten varR = 1, _c = 0, C = 0, RS = 0, CS = 0; One var_title = Title | | ""; A varTitle_o = {t: ' s ', V: _title, s:oss}; -Ws[encode_cell ({c:0, r:0})] =title_o; - varMAXC = 0; the for(; R < sheetrows+1; ++R) { - varNR = R-1 - varrow =ROWS[NR]; - varELTs =(Row.children); + for(_c = C = 0; _c < elts.length; + +)_c) { - varELT = Elts[_c], V =HtmlDecode (elts[_c].innerhtml); + for(midx = 0; midx < merges.length; + +midx) { A varm =Merges[midx]; at if(M.S.C = = C && M.S.R <= r && R <=M.E.R) { -C = m.e.c + 1; Midx =-1; - } - } - /*Todo:figure out how to extract nonstandard Mso-style*/ -CS = +elt.getattribute ("colspan") | | 1; in if(RS = +elt.getattribute ("rowspan") > 0 | | CS > 1) -Merges.push ({s: {r:r, c:c}, E: {r:r + (RS | | 1)-1, C:c + CS-1 } }); to varo = {t: ' s ', V:v, s:oss}; + var_t = Elt.getattribute ("t") | | ""; - if(V! =NULL) { the if(V.length = = 0) o.t = _t | | ' Z '; * Else if(Opts.raw | | V.trim (). Length = = 0 | | _t = = "S") { } $ Else if(v = = ' TRUE ') o = {t: ' B ', V:true, s:oss};Panax Notoginseng Else if(v = = = ' FALSE ') o = {t: ' B ', V:false, s:oss}; - Else if(!isnan (Fuzzynum (v))) o = {t: ' n ', V:fuzzynum (v), s:oss}; the Else if(!IsNaN (Fuzzydate (v). GetDate ())) { +o = ({t: ' d ', V:parsedate (v), s:oss}); A if(!opts.celldates) o = ({t: ' n ', V:datenum (O.V), s:oss}); theo.z = Opts.datenf | | Ssf._table[14]; + } - } $ if(Opts.dense) {if(!ws[r]) ws[r] = []; WS[R][C] =o;} $ ElseWs[encode_cell ({c:c, r:r})] =o; - /*merge data processing started*/ - if(CS! = 1) { the for(vari = 1; i < CS; i++) { - varNEWC = C +IWuyi if(RS! = 1) { the for(varm = 1; M < RS; m++) { - varNEWR = R +m; WuWs[encode_cell ({c:newc, r:newr})] =o; - } About } $ Else { -Ws[encode_cell ({c:newc, r:r})] =o; - } - } A } + Else { the if(RS! = 1) { - for(varm = 1; M < RS; m++) { $ varNEWR = R +m; theWs[encode_cell ({c:c, r:newr})] =o; the } the } the } - /*end of combined data processing*/ in if(Range.e.c < c) Range.e.c =C; theC + =CS; the if(Maxc <C) About { theMAXC =C; the } the } + if(R = =sheetrows) - { theMerges.push ({s: {r:0, c:0}, E: {r:0, c:maxc-1 } });Bayi } the } thews['!merges '] =merges; -ws['!ref '] =Encode_range (range); - if(Sheetrows < Rows.length) ws['!fullref '] = Encode_range ((RANGE.E.R = rows.length-1, Range)); the returnws; the}
"Js-xlsx and File-saver plug-in" front-end HTML table export data to Excel table Add table header row