activex - Reading xls or xlsx file using javascript -


i reading 1 xls file through java script.

function upload1() {     var controlcn = new activexobject("adodb.connection");     var conn = "provider=microsoft.jet.oledb.4.0;data source = c:\\test.xls;persist security info=false;extended properties=excel 8.0;";     controlcn.open(conn);     var rs = new activexobject("adodb.recordset");     var sql = "select * [sheet1$]";     rs.open(sql, controlcn);     if(rs.bof)     {         document.write('no data avaliable');     }      if(!rs.bof)     {         rs.movefirst()         while(!rs.eof)         {             for(var i=0; i!= rs.fields.count; ++i)             {                                             document.write(rs.fields(i).value + ", ");             }             document.write("<br />");             rs.movenext()         }     }     rs.close();     controlcn.close();  } 

in third line giving path of xls file want read. possible dynamically fetch excel file through 1 browse button<input type="flie" ...

you can try below:

<input type="file" id="myexcelfile"/> 

once user browses file, can path below:

var filepath=document.getelementbyid("myexcelfile").value; 

you can use "filepath" variable in code passing excel sheet name


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -