////DocName:导入模板数据功能--Fxjc_ExcelDatasIntoSqlDatas.js
////Author:lify
////Company:Wavenet
////Date:2010-03-12
////EditDate:2010-03-12
////MainContent:Findings,Ajax And So On;
//////////////////////////////////////////////////////////////////////////////////////////////////
var excelFileName=""; //本地EXCEL地址
var oWB;
var idTmr="";
function AutomateExcel3()
{
//删除PT表的除前2行的所有行
DeleteTablePT();
//alert(pic_path+document.getElementById("ImgUrl").value);//测试
var xls=null;
var newBook;
try{
xls = new ActiveXObject("Excel.Application");
}catch(e){openBg(0);openTS(0);
alert("请您打开ActiveX控件,具体操作:单击IE中的“工具”里“Internet 选项”,单击“安全”中的“自定义级别”中“ActiveX控件和插件”中,请选择第三项为启用即可。详细错误:"+e.message);
return ;
}
if (xls == null){openBg(0);openTS(0);
alert("创建Excel文件失败,可能是您的计算机上没有正确安装Microsoft Office Excel软件或浏览器的安全级别设置过高!");
return;
}
try{
newBook = xls.Workbooks.Open(excelFileName);//这里的Add方法里的参数是模板的路径
}catch(e){openBg(0);openTS(0);
alert("加载的Excel文件路径有错误!详细:"+e.message);
return ;
}
var oSheet=newBook.ActiveSheet;
////////////////////////////////////////////模板写入数据到WEB页面中////////////////////////////////////////////////////////////
var xhnum=0;
//alert("oSheet.Cells(3,18).value="+oSheet.Cells(3,18).value+"|"+(oSheet.Cells(3,5).value=="for(var i=3;i{
if(oSheet.Cells(i,1).value)
{
xhnum++;
var newRow = document.getElementById("PT").insertRow(-1);
var newCell;
newRow.align = "center";
newRow.height = "35px";
for(var j=0;j{
if(j==4)
{
//什么都不做
}
else if(j{
newCell = newRow.insertCell(j);
if(j==0) newCell.innerHTML = (xhnum).toString();//序号
else if(j==1)
{
if(!oSheet.Cells(i,1).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,1).value=="——"||oSheet.Cells(i,1).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,1).value==""?" ":oSheet.Cells(i,1).value);
}
else if(j==2)
{
if(!oSheet.Cells(i,2).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,2).value=="——"||oSheet.Cells(i,2).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,2).value==""?" ":oSheet.Cells(i,2).value);
//newCell.innerHTML = (oSheet.Cells(i,2).value==""?" ":oSheet.Cells(i,2).value);
}
else if(j==3)
{
if(!oSheet.Cells(i,4).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,4).value=="——"||oSheet.Cells(i,4).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,4).value==""?" ":oSheet.Cells(i,4).value);
//newCell.innerHTML = (oSheet.Cells(i,4).value==""?" ":oSheet.Cells(i,4).value);
}
else if(j==9)
{
if(!oSheet.Cells(i,j+1).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,j+1).value=="newCell.innerHTML = "30";
else if(oSheet.Cells(i,j+1).value=="——"||oSheet.Cells(i,j+1).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,j+1).value==""?" ":oSheet.Cells(i,j+1).value);
}
else
{
if(!oSheet.Cells(i,j+1).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,j+1).value=="newCell.innerHTML = "30";
else if(oSheet.Cells(i,j+1).value=="
newCell.innerHTML = " ";
else if(oSheet.Cells(i,j+1).value=="——"||oSheet.Cells(i,j+1).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,j+1).value==""?" ":oSheet.Cells(i,j+1).value);
}
}
else
{
newCell = newRow.insertCell(j-1);//少一个就可以了,少样品编号插入
if(j==0) newCell.innerHTML = (xhnum).toString();//序号
else if(j==1)
{
if(!oSheet.Cells(i,1).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,1).value=="——"||oSheet.Cells(i,1).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,1).value==""?" ":oSheet.Cells(i,1).value);
}
else if(j==2)
{
if(!oSheet.Cells(i,2).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,2).value=="——"||oSheet.Cells(i,2).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,2).value==""?" ":oSheet.Cells(i,2).value);
//newCell.innerHTML = (oSheet.Cells(i,2).value==""?" ":oSheet.Cells(i,2).value);
}
else if(j==3)
{
if(!oSheet.Cells(i,4).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,4).value=="——"||oSheet.Cells(i,4).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,4).value==""?" ":oSheet.Cells(i,4).value);
//newCell.innerHTML = (oSheet.Cells(i,4).value==""?" ":oSheet.Cells(i,4).value);
}
else if(j==9)
{
if(!oSheet.Cells(i,j+1).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,j+1).value=="newCell.innerHTML = "30";
else if(oSheet.Cells(i,j+1).value=="——"||oSheet.Cells(i,j+1).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,j+1).value==""?" ":oSheet.Cells(i,j+1).value);
}
else
{
if(!oSheet.Cells(i,j+1).value)
newCell.innerHTML = " ";
else if(oSheet.Cells(i,j+1).value=="newCell.innerHTML = "30";
else if(oSheet.Cells(i,j+1).value=="newCell.innerHTML = " ";
else if(oSheet.Cells(i,j+1).value=="——"||oSheet.Cells(i,j+1).value=="--")
newCell.innerHTML = " ";
else
newCell.innerHTML = (oSheet.Cells(i,j+1).value==""?" ":oSheet.Cells(i,j+1).value);
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newBook.Close();
newBook=null;
xls = null;
openBg(0);openTS(0);
///////////////////////////////开启编辑和保存按钮功能///////////////////////////////////
OnOrOffBtn(1);
////////////////////////////////////////////////////////////////////////////////////////
idTmr = window.setInterval("Cleanup();",1);
////////////////////////////////表格数字和字符转化//////////////////////////////////////
TableIntoDatas();////表格数字和字符转化
////////////////////////////////////////////////////////////////////////////////////////
}