function readExcel(path) {
var oXL = new ActiveXObject("Excel.Application");
try{
var oWB = oXL.Workbooks.open(path);
}catch(e){
alert('打开文件失败!');
return;
}
var oSheet = oWB.ActiveSheet;
var rowsCount = oSheet.usedrange.rows.count;
for(var i=1;i<=rowsCount;i++){
addNewRow2(oSheet.Cells(i,1).value,oSheet.Cells(i,2).value);//进行表格操作
}
oSheet=null;
oWB.close();
oXL=null;
}
function getFullPath(obj){
if(obj){
//ie
if (window.navigator.userAgent.indexOf("MSIE")>=1){
obj.select();
return document.selection.createRange().text;
}
//firefox
else if(window.navigator.userAgent.indexOf("Firefox")>=1){
if(obj.files)return obj.files.item(0).getAsDataURL();
return obj.value;
}
return obj.value;
}
}
function importFile(){
var path=getFullPath($("#importFile"));
if(path=="") return;
readExcel(path);
$("#divEdit2").hide();
}
var oXL = new ActiveXObject("Excel.Application");
try{
var oWB = oXL.Workbooks.open(path);
}catch(e){
alert('打开文件失败!');
return;
}
var oSheet = oWB.ActiveSheet;
var rowsCount = oSheet.usedrange.rows.count;
for(var i=1;i<=rowsCount;i++){
addNewRow2(oSheet.Cells(i,1).value,oSheet.Cells(i,2).value);//进行表格操作
}
oSheet=null;
oWB.close();
oXL=null;
}
function getFullPath(obj){
if(obj){
//ie
if (window.navigator.userAgent.indexOf("MSIE")>=1){
obj.select();
return document.selection.createRange().text;
}
//firefox
else if(window.navigator.userAgent.indexOf("Firefox")>=1){
if(obj.files)return obj.files.item(0).getAsDataURL();
return obj.value;
}
return obj.value;
}
}
function importFile(){
var path=getFullPath($("#importFile"));
if(path=="") return;
readExcel(path);
$("#divEdit2").hide();
}