function Co_Export(formObj,sSingleCmd, sCtrlId,nPos) {
var a=formObj;
var a=sSingleCmd;
var a=sCtrlId;
var a=nPos;
var vscmd = sSingleCmd.substring(nPos + 9,sSingleCmd.length);
vscmd = ScanStr(formObj,vscmd,0,2,0,0);
//获取后台传入的业务表单编号
var ywbdid=vscmd.substring(1,vscmd.length-1);
/**
* 声明属性
*/
var btmc="";//标题名称
var year="";//标题名称
/**
* 获取动态加载值
*/
//btmc=document.getElementsByName("SingelEdit_40").value;
//alert("btmc="+btmc);
//year=document.getElementsByTagName("征地年份").value;
//alert("year="+year);
/**
* 导出excel
*/
var oXL = new ActiveXObject("Excel.Application"); //创建excel应用程序对象
var oWB = oXL.Workbooks.Add(); //创建工作簿
var oSheet = oWB.ActiveSheet; //获取当前活动的工作簿
oSheet.Rows("1:30").ColumnWidth =18;
var table = document.all.myTaskTable; //获取当前页面中的表格
// var hang = table.rows.length; //获取表格有多少行
// var count = selectedCheckBoxArr.size(); //获取表格有多少行
// var lie = table.rows(0).cells.length; //获取首行有多少列-多少标题
//格式设置
/*oSheet.Cells(1,1).Font.Bold = true;//加粗
oXL.Range("A2:K2").Font.Bold = true;//加粗
oXL.Range("A1:K1").MergeCells = true;//合并
oSheet.Cells(1,10).HorizontalAlignment = 7;//居中
oSheet.Cells(1,1).Font.Size = 20;
oSheet.Cells(2,1).Font.Size = 12; */
//标题设置
oSheet.Cells(1,3).RowHeight=40;
oSheet.Columns('A:E').ColumnWidth = 15;
//提取对应导出表单的表头信息
$.post("exportAction_getCfg.do",{id:ywbdid},
function(data){
var str=data[0].lbm.split(";");
var liecell;
for(var ii=0;ii var strs=str[ii].split(","); oSheet.Cells(1,1).Font.Bold = true;//加粗 var a=String.fromCharCode(65+strs.length-1);//ASCII 值的提取获得对应字符 oXL.Range("A"+(ii+2)+":"+a+'3').Font.Bold = true;//加粗 oXL.Range("A1:"+a+'1').MergeCells = true;//合并 oSheet.Cells(1,strs.length).HorizontalAlignment = 7;//居中 oSheet.Cells(1,1).Font.Size = 20; oSheet.Cells(2,1).Font.Size = 12; oSheet.Cells(1,1).Value = data[0].xznf+" "+data[0].bt;//标题 var hangcell; var hang2cell; var currentcell; var n; for(var i=0;i currentcell=strs[i]; oSheet.Cells(2+ii,i+1).Value = strs[i]; var hq=String.fromCharCode(65+i);//合并的前cell var hh=String.fromCharCode(65+(i+1));//合并的当前cell debugger; var qiancurrentcell; if(ii>0){ qiancurrentcell=str[ii-1].split(",")[(i-1)] } if(currentcell!=qiancurrentcell){ if(hangcell==currentcell){//针对每行的处理,如果上个单元格与当前单元格内容相同,择执行合并 hq=String.fromCharCode(65+(i-1));//合并的前cell hh=String.fromCharCode(65+i);//合并的当前cell var hbys=hq+(ii+2)+":"+hh+(ii+2);//组合的元素,示例:"A2:B2" //oSheet.Cells(i,(i+1)).HorizontalAlignment =3;//居中 oXL.Range(hbys).MergeCells = true;//合并 } } hangcell=strs[i]; if(ii var strs2=str[ii+1].split(","); hang2cell=strs2[i]; if(hang2cell==hangcell){//如果第二行的列与第一行的列单元格值相同,择执行合并 var lq=hq+(ii+2); var lh=hq+(ii+(2+1));//默认是从第三行进行处理 var lbys=lq+":"+lh;//组合的元素,示例:"A2:A3" oXL.Range(lbys).MergeCells = true;//合并 n=hang2cell; } else{ oSheet.Cells(2+(ii+1),i+1).Value = strs2[i]; } } } } //获取excel内容 $.ajax({ type:"post", url:"exportAction_exportData.do?id="+ywbdid+"",//通过控制器调用后台 dataType:"json", async: false, success:function(data){ for(i=0;i oSheet.Cells(i+(str.length+2),1).Value = data[i].bzddw; oSheet.Cells(i+(str.length+2),2).Value = data[i].zdmj; oSheet.Cells(i+(str.length+2),3).Value = data[i].xm; oSheet.Cells(i+(str.length+2),4).Value = data[i].wz; oSheet.Cells(i+(str.length+2),(str.length+2)).Value = data[i].zdk; oSheet.Cells(i+(str.length+2),6).Value = data[i].fzwbc; oSheet.Cells(i+(str.length+2),7).Value = data[i].qt; oSheet.Cells(i+(str.length+2),8).Value = data[i].zjk; oSheet.Cells(i+(str.length+2),9).Value = data[i].xyqdrq; oSheet.Cells(i+(str.length+2),10).Value = data[i].bh; oSheet.Cells(i+(str.length+2),11).Value = data[i].bz; } }, error:function(){ alert('暂无数据!'); } }); oXL.Visible = true; //设置Excel的属性 oXL.UserControl = true; },"json"); } webform.CoReg('Co_Export', Co_Export);