- vardataXMLDOC;varoptionsFlags;varoptionsValues=newArray();////记录:表名|字段名|type|id|memo|extendtype|baseinfovariteminfoValues=newArray();//纪录总的复合信息集的信息varoptionvalue="";
functiondivideOptionValue(optionvalue){//optionvalue="epmsTirpTbl|vcCommon001ID|1|1|序列号|610001|0";temp=optionvalue;i=0;while(temp.indexOf("|")!=-1){loc=temp.indexOf("|");optionsValues[i]=temp.substring(0,loc);i++;temp=temp.substring(loc+1);}optionsValues[i]=temp;//baseinfo}
functiondeleteXmlNode(form,deledcell){activecell=deledcell;
for(i=0;i
} } } varinnodelen=dataXMLDOC.documentElement.childNodes.length; for(ip=0;ip
functionModifyStyle(form)//提交更改后的报表样式{form.action="";form.submit();}
functionOnLoadData(stylepath,datapath){Spreadsheet.HTMLURL=stylepath.value;xmlDoc.load(datapath.value);for(x=0;x
if(allinfoarray[0]=="0"){varrows=Spreadsheet.Selection.Rows.Count;varcols=Spreadsheet.Selection.Columns.Count;varbeginrow=Spreadsheet.Selection.row;varbegincol=Spreadsheet.Selection.column;vardefinedNode;varactivecell=Spreadsheet.ActiveCell;vardatanode;varseledtable;defined=true;varselectIndex=-1;//选中的optionvarkkkk;if(true){ nodecount=0; data=allinfoarray[3]; optionsValues=data.split("&");
fieldname=optionsValues[1];//字段名称 activecell=Spreadsheet.ActiveCell;//Excel对象的活动cell for(i=0;i
i=activecell.row; j=activecell.column; newDataNode.setAttribute("row",i); newDataNode.setAttribute("col",j); newDataNode.setAttribute("name",optionsValues[2]); newDataNode.setAttribute("showname",optionsValues[4]); newDataNode.setAttribute("type",optionsValues[3]); if(optionsValues[3]=="3") { newDataNode.setAttribute("format","yy-MM-dd"); } if(optionsValues[5]!=""&&optionsValues[5]!=null) { newDataNode.setAttribute("code",optionsValues[5]); } if(optionsValues[6]!=""&&optionsValues[6]!=null) { newDataNode.setAttribute("consql",optionsValues[6]); } chfieldname=optionsValues[4]; } else {newDataNode=datanode;dataElement=dataXMLDOC.documentElement; dataElement.appendChild(newDataNode); newDataNode=dataXMLDOC.createElement("field");
i=activecell.row; j=activecell.column; newDataNode.setAttribute("row",i); newDataNode.setAttribute("col",j); newDataNode.setAttribute("name",optionsValues[2]); newDataNode.setAttribute("showname",optionsValues[4]); newDataNode.setAttribute("type",optionsValues[3]); if(optionsValues[3]=="3") { newDataNode.setAttribute("format","yy-MM-dd"); } if(optionsValues[5]!=""&&optionsValues[5]!=null) { newDataNode.setAttribute("code",optionsValues[5]); } if(optionsValues[6]!=""&&optionsValues[6]!=null) { newDataNode.setAttribute("consql",optionsValues[6]); } //newDataNode.setAttribute("rep","0"); chfieldname=optionsValues[4]; }
for(x=0;x
for(x=0;x
}else//该字段已经定义过{ kkkk=-1; for(x=0;x
}}
data=form.queryfield.options[selectIndex].value;//data="epmsTirpTbl|vcCommon001ID|1|1|序列号|610001|0";//表名|字段名|type|id|memo|extendtype|baseinfo//divideOptionValue(data);//分隔 optionsValues=data.split("$"); fieldname=optionsValues[1];
for(x=0;x
elseif((allinfoarray[0]=="1")){//alert("iteminfoValues:"+allinfoarray[2]);iteminfoValues=allinfoarray[2].split("^");varrows=Spreadsheet.Selection.Rows.Count;varcols=Spreadsheet.Selection.Columns.Count;varbeginrow=Spreadsheet.Selection.row;varbegincol=Spreadsheet.Selection.column;vardefinedNode;varactivecell=Spreadsheet.ActiveCell;vardatanode;varseledtable;defined=true;varselectIndex=-1;//选中的optionvarkkkk;//alert("iteminfoValues.length-1:"+(iteminfoValues.length-1));for(tt=0;tt
i=activecell.row; j=activecell.column; newDataNode.setAttribute("row",i); newDataNode.setAttribute("col",j+tt); newDataNode.setAttribute("condition",""); //newDataNode.setAttribute("actcount","0"); newDataNode.setAttribute("name",optionsValues[2]); newDataNode.setAttribute("showname",optionsValues[4]); newDataNode.setAttribute("type",optionsValues[3]); if(optionsValues[3]=="3") { newDataNode.setAttribute("format","yy-MM-dd"); } if(optionsValues[5]!=""&&optionsValues[5]!=null) { newDataNode.setAttribute("code",optionsValues[5]); } if(optionsValues[6]!=""&&optionsValues[6]!=null) { newDataNode.setAttribute("consql",optionsValues[6]); } //newDataNode.setAttribute("rep","1"); chfieldname=optionsValues[4]; rowrow=i; colcol=j+tt; }
for(x=0;x
for(x=0;x
if(chfieldname.indexOf(".")!=-1) { activecell.value="["+chfieldname.substring(chfieldname.indexOf(".")+1)+"]"; }else { //activecell.value="["+chfieldname+"]"; Spreadsheet.Cells(rowrow,colcol).value="["+chfieldname+"]"; }//optionsFlags[selectIndex]=true;//标记选择过}else//该字段已经定义过{ kkkk=-1; for(x=0;x
}}
data=form.queryfield.options[selectIndex].value;//data="epmsTirpTbl|vcCommon001ID|1|1|序列号|610001|0";//表名|字段名|type|id|memo|extendtype|baseinfo//divideOptionValue(data);//分隔 optionsValues=data.split("$"); fieldname=optionsValues[1];
for(x=0;x
}}
else{iteminfoValues=allinfoarray[2].split("^");vardefinedNode;vardatanode;varseledtable;defined=true;varselectIndex=-1;//选中的optionvarkkkk;for(tt=0;tt
vareqcount=0; for(eqc=0;eqc
for(x=0;x
if(chfieldname.indexOf(".")!=-1) { activecell.value="["+chfieldname.substring(chfieldname.indexOf(".")+1)+"]"; }else { }}}if(allinfoarray[0]!="0"){//alert("allinfoarray[0]!=0");parsecondition(allinfoarray[3],allinfoarray[0]);}}
functionparsecondition(str,rep){ vartmpstring; //alert("parsecondition(str:"+str); //alert("rep:"+rep); iteminfoValues=str.split("^"); for(tt=0;tt
if(rep=="2") { //去除未设条件的节点 vartmpvalue; //vartmparraya; for(i=0;i
functiontrimand()//去除and{ vartmpvalue; //vartmparraya; for(i=0;i
functionShowGraph()//显示选中区域的统计图{ChartSpace1.style.display="";ChartSpace2.style.display="";varcolname=newArray(502);varletters=newArray(26);colname[0]="A";colname[1]="B";colname[2]="C";colname[3]="D";colname[4]="E";colname[5]="F";colname[6]="G";colname[7]="H";colname[8]="I";colname[9]="J";colname[10]="K";colname[11]="L";colname[12]="M";colname[13]="N";colname[14]="O";colname[15]="P";colname[16]="Q";colname[17]="R";colname[18]="S";colname[19]="T";colname[20]="U";colname[21]="V";colname[22]="W";colname[23]="X";colname[24]="Y";colname[25]="Z";letters[0]="A";letters[1]="B";letters[2]="C";letters[3]="D";letters[4]="E";letters[5]="F";letters[6]="G";letters[7]="H";letters[8]="I";letters[9]="J";letters[10]="K";letters[11]="L";letters[12]="M";letters[13]="N";letters[14]=软件定制"O";letters[15]="P";letters[16]="Q";letters[17]="R";letters[18]="S";letters[19]="T";letters[20]="U";letters[21]="V";letters[22]="W";letters[23]="X";letters[24]="Y";letters[25]="Z";
vara=0,b=0;//AAABAC...BABBBC...ZZfor(x=26;x<502;x++){if(b==25){b=0;a++;}colname[x]=letters[a]+letters[b];b++;}
rows=Spreadsheet.Selection.Rows.Count;cols=Spreadsheet.Selection.Columns.Count;beginrow=Spreadsheet.Selection.row;begincol=Spreadsheet.Selection.column;varstr1="",str2="",str3="",str4="",str5="",str6="";str1=colname[begincol-1]+(beginrow+1)+":"+colname[begincol-1]+(beginrow+rows-1);str2=colname[begincol]+(beginrow)+":"+colname[begincol+cols-2]+(beginrow);str3=colname[begincol]+(beginrow+1)+":"+colname[begincol+cols-2]+(beginrow+rows-1);
BindChartToSpreadSpreadsheet(ChartSpace1,SS,str1,str2,str3,false);BindChartToSpreadSpreadsheet(ChartSpace2,SS,str2,str1,str3,true);
//BindChartToSpreadSpreadsheet(ChartSpace1,SS,"a2:a4","b1:c1","b2:c4",false);//BindChartToSpreadSpreadsheet(ChartSpace2,SS,"b1:c1","a2:a4","b2:c4",true);}
//将图表数据源绑定到电子表格functionBindChartToSpreadSpreadsheet(ChartSpace,Spreadsheet,RangeRound1,RangeRound2,RangeData,DisplayType){c=ChartSpace.Constants;ChartSpace.Clear();ChartSpace.DataSource=Spreadsheet;
cht=ChartSpace.Charts.Add();cht.HasLegend=true;
cht.SetData(c.chDimSeriesNames,0,RangeRound1);cht.SetData(c.chDimCategories,0,RangeRound2);
rngValues=Spreadsheet.Range(RangeData);//取数据
for(i=0;i
}else{ser.SetData(c.chDimValues,0,rngValues.Columns(ser.Index+1).Address);varchartwidth;if(Spreadsheet.Range(RangeRound1).Columns.Count>Spreadsheet.Range(RangeRound2).Rows.Count)chartwidth=Spreadsheet.Range(RangeRound1).Columns.Count+2;elsechartwidth=Spreadsheet.Range(RangeRound2).Rows.Count+2;ChartSpace.style.width=parseInt(chartwidth)*50;}//dl=ser.DataLabelsCollection.Add();//dl.Font.Size=9;//dl.Font.Color="blue";//dl.Position=c.chLabelPositionTop;}//endfor(i=0....
FormatChart(c,cht);
}
//设置图表显示字体及数据轴格式functionFormatChart(c,cht){
cht.Legend.Font.size=9;ax=cht.Axes(c.chAxisPositionBottom);ax.Font.Size=9;ax=cht.Axes(c.chAxisPositionLeft);ax.Font.Size=9;ax.NumberFormat="$#,##0";
}
functionselectinfo(form,infostr){ vararray=newArray(); array=infostr.split("^"); //已经得到这些变量vartablename=array[0];//表名varkey=array[1];//主键varinstance=array[2];//实例IDvarfieldname=array[3];//字段名称varshowname=array[4];//字段显示的中文名称varflag=array[5];//字段vartype=array[6];//字段类型varcode=array[7];//字段对应的代码项vartypeflag=array[8];//日期型显示的格式varformat;//字段格式varexcelname;//在Excel中要显示的字段名称,其实就是shownamevarrows=Spreadsheet.Selection.Rows.Count;varcols=Spreadsheet.Selection.Columns.Count;varbeginrow=Spreadsheet.Selection.row;varbegincol=Spreadsheet.Selection.column;vardefinedNode;varactivecell=Spreadsheet.ActiveCell;vardatanode;varseledtable;defined=true;varselectIndex=-1;//选中的optionif(true){ nodecount=0; activecell=Spreadsheet.ActiveCell;//Excel对象的活动cell //判断xml中有没有这个表 for(i=0;i
//如果没有这个表的话,就在xml中创建这个表if(nodecount==dataXMLDOC.documentElement.childNodes.length){newDataNode=dataXMLDOC.createElement("table");newDataNode.setAttribute("name",tablename);newDataNode.setAttribute("key",key);newDataNode.setAttribute("instance",instance);dataElement=dataXMLDOC.documentElement;dataElement.appendChild(newDataNode);newDataNode=dataXMLDOC.createElement("field");
i=activecell.row;j=activecell.column;newDataNode.setAttribute("row",i);newDataNode.setAttribute("col",j);newDataNode.setAttribute("name",fieldname);newDataNode.setAttribute("showname",showname);newDataNode.setAttribute("flag",flag);newDataNode.setAttribute("type",type);newDataNode.setAttribute("typeflag",typeflag);if(code!=""&&code!=null){ newDataNode.setAttribute("code",code);}excelname=showname;//把字段显示名称赋给Excel单元格}//如果有这个表的话,就在xml中追加这个表的元素else{ newDataNode=datanode;//table元素dataElement=dataXMLDOC.documentElement;dataElement.appendChild(newDataNode);//追加元素newDataNode=dataXMLDOC.createElement("field");
i=activecell.row;j=activecell.column;newDataNode.setAttribute("row",i);newDataNode.setAttribute("col",j);newDataNode.setAttribute("name",fieldname);newDataNode.setAttribute("flag",flag);newDataNode.setAttribute("showname",showname);newDataNode.setAttribute("type",type);newDataNode.setAttribute("typeflag",typeflag);if(code!=""&&code!=null){newDataNode.setAttribute("code",code);}
excelname=showname;//把字段显示名称赋给Excel单元格
}//如果有相同的元素,就把Excel的元素删掉for(x=0;x
for(x=0;x