js读取excel文档记录...
时间:2010-08-09 来源:paopao00o
/**
* 拼装导入数据二元数组
* @param {} filepath
* @return {}
*/
this.readExcel=function (filepath)
{
try
{
var oXL = new ActiveXObject("Excel.Application");
var oWB = oXL.Workbooks.open(filepath);
}catch(e)
{
alert('打开文件失败!');
}
var oSheet = oWB.ActiveSheet;
var exceldata=new Array(oSheet.usedrange.rows.count-3);
for(i=4;i<=oSheet.usedrange.rows.count;i++)
{
var datavalue=new Array(29);
datavalue[0]=this.groupid;
datavalue[1]=oSheet.Cells(i,1).value;
datavalue[2]=oSheet.Cells(i,2).value;
datavalue[3]=oSheet.Cells(i,3).value;
datavalue[4]=oSheet.Cells(i,4).value;
datavalue[5]=oSheet.Cells(i,5).value;
datavalue[6]=oSheet.Cells(i,6).value;
datavalue[7]=oSheet.Cells(i,7).value;
datavalue[8]=oSheet.Cells(i,8).value;
datavalue[9]=oSheet.Cells(i,9).value;
datavalue[10]=oSheet.Cells(i,10).value;
datavalue[11]=oSheet.Cells(i,11).value;
datavalue[12]=oSheet.Cells(i,12).value;
datavalue[13]=oSheet.Cells(i,13).value;
datavalue[14]=oSheet.Cells(i,14).value;
datavalue[15]=oSheet.Cells(i,15).value;
datavalue[16]=oSheet.Cells(i,16).value;
datavalue[17]=oSheet.Cells(i,17).value;
datavalue[18]=oSheet.Cells(i,18).value;
datavalue[19]=oSheet.Cells(i,19).value;
datavalue[20]=oSheet.Cells(i,20).value;
datavalue[21]=oSheet.Cells(i,21).value;
datavalue[22]=oSheet.Cells(i,22).value;
datavalue[23]=oSheet.Cells(i,23).value;
datavalue[24]=oSheet.Cells(i,24).value;
datavalue[25]="";
datavalue[26]=LEAP.userInfo.userflag;
datavalue[27]=LEAP.userInfo.positionid;
datavalue[28]=LEAP.request('getTopOrgID');
exceldata[i]=datavalue;
}
oSheet=null;
oWB.close();
oXL=null;
return exceldata;
}