javascript - how to count headers of excel file -
i using script excel html table conversion working basis oflimited no of column , row provide initialy want works on basis or row , column given in excel file
<script> function _ge(id) { return document.getelementbyid(id); } function _nc(val) { return (val != null && val.length > 0); } function convert2html() { var fo = _ge('file1'); var = _ge('txtsheetname'); var ho = _ge('txtheaderrowstart'); var co = _ge('txtheadercolstart'); var hco = _ge('txtheadercols'); var ro = _ge('txtdatarows'); if (!(_nc(fo.value) && _nc(so.value) && _nc(ho.value) && _nc(co.value) && _nc(hco.value) && _nc(ro.value))) { alert('all fields mandatory.'); return false; } var ex; try { ex = new activexobject("excel.application"); } catch (e) { alert('your browser not support activex object.\nplease switch internet explorer.'); return false; } var ef = ex.workbooks.open(fo.value, true); var es = ex.worksheets(so.value); var rs = parseint(ho.value, 10); var cs = parseint(co.value, 10); var ce = cs + parseint(hco.value, 10) - 1; var re = rs + parseint(ro.value, 10); var oc = _ge('chartcontainer'); oc.innerhtml = ''; var tbl = document.createelement('table'); tbl.id = 'tblexcel2html'; tbl.border = '0'; tbl.cellpadding = '4'; tbl.cellspacing = '0'; oc.appendchild(tbl); var i, j, row, col, r, c; (i = rs, r = 0; <= re; i++, r++) { row = tbl.insertrow(r); row.classname = (i == rs) ? 'tblheader' : (i % 2 == 0) ? 'evenrow' : 'oddrow'; (j = cs, c = 0; j <= ce; j++, c++) { col = row.insertcell(c); col.classname = (j == ce) ? 'lastcol' : ''; col.innerhtml = es.cells(i, j).value || ' '; } } _ge('btngetsrc').style.display = ''; } function togglesrc() { if (_ge('chartcontainer').style.display == '') { gethtmlsrc(); } else { back2table(); } } function gethtmlsrc() { var oc = _ge('chartcontainer'); var tx = _ge('txtoutput'); var = document.getelementsbytagname('style'); var str = '<html><body>' + oc.outerhtml + so[0].outerhtml + '</body></html>'; tx.value = str; oc.style.display = 'none'; _ge('divoutput').style.display = ''; } function copy2clipboard() { var tx = _ge('txtoutput'); window.clipboarddata.setdata("text", tx.value); } function resetfields() { window.location.reload(); } function back2table() { _ge('divoutput').style.display = 'none'; _ge('btngetsrc').style.display = ''; _ge('chartcontainer').style.display = ''; } function numberonly(obj) { obj.value = obj.value.replace(/[^0-9]*/, ''); } </script>
i using script excel html table conversion working basis oflimited no of column , row provide initialy want works on basis or row , column given in excel file
Comments
Post a Comment