📄 olap_func.jsp
字号:
<SCRIPT LANGUAGE=javascript>//Boco @2003//关闭窗口function closeWindow(){history.back()}//打印function PrintTable(){ViewComp.run("print");}//显示表格function Disptable() { ViewComp.setPropertyValueString("ViewDisplayType",0) //ShowChart(false);}//显示图形function DispPic() { ViewComp.setPropertyValueString("ViewDisplayType",1) //ShowChart(false);}//自定义function Define() { ViewComp.run("SetDimension");}//定义显示图类型function setChartType(ChartType){ ViewComp.setPropertyValueString("ViewDisplayType",ChartType)}//过滤日期 function AddDim(ViewComp, year_start, year_end, month_start, month_end,day_start,day_end){ var strDim, temp, n,date_start,date_end,year_temp,month_temp,day_temp,year,month,day; if (ViewComp == null) exit; if (year_end < year_start) { temp = year_end; year_end = year_start; year_start = temp; temp = month_end; month_end = month_start; month_start = temp; temp=day_end; day_end=day_start; day_start=temp; } else if(year_end == year_start) { if(month_end < month_start) { temp = month_end; month_end = month_start; month_start = temp; temp=day_end; day_end=day_start; day_start=temp; } else if(month_end == month_start) { if(day_end < day_start) { temp=day_end; day_end=day_start; day_start=temp; } } } //date_start=year_start+"-"+month_start+"-"+day_start; //date_end=year_end+"-"+month_end+"-"+day_end; //alert(date_start+"st"); //alert(date_end+"end"); strDim = ""; n = 0; for(year = year_start; year <=year_end; year++) { month = year==year_start ? month_start:1; month_to = year==year_end ? month_end:12; for ( month; month <= month_to; month++) {day =month==month_start?day_start:1; day_to =month==month_end ?day_end:getDays(year,month); for ( day; day <= day_to; day++){ //strDim = strDim + ";" + "0;" + year +"年"+ month+"月"+day+"日"; strDim = strDim + ";" + "0;" + year +"年" + getSeason(month) + month+"月"+day+"号"; n++; } } } strDim = "时间;F0;" + n +strDim; alert(strDim); ViewComp.run("SetAllDimensions", 1, strDim);}//得到季度维字符串function getSeason(month){ var strSeason; //if (month!=null){ if (month>0 && month<4){ strSeason = "上半年1季度"; } if (month>3 && month<7){ strSeason = "上半年2季度"; } if (month>6 && month<10){ strSeason = "下半年3季度"; } if (month>9 && month<13){ strSeason = "下半年4季度"; } //} return strSeason;}//得到某月的天数function getDays(WhichYear,WhichMonth){ if(WhichMonth=='1'||WhichMonth=='3'||WhichMonth=='5'||WhichMonth=='7'||WhichMonth=='8'||WhichMonth=='10'||WhichMonth=='12'){ var Daylength = 31; } if(WhichMonth=='4'||WhichMonth=='6'||WhichMonth=='9'||WhichMonth=='11'){ var Daylength = 30; } if(WhichMonth=='2'&&(WhichYear%4!=0)){ var Daylength = 28; } if(WhichMonth=='2'&&(WhichYear%4==0)){ var Daylength = 29; } return Daylength;}//选择时间或时间段function SetDateQuerytype(){ if (IsPeriod.value=="1") { txt1.style.display="block"; ryear_end.style.display="block"; txtyear_end.style.display="block"; rmonth_end.style.display="block"; txtmonth_end.style.display="block"; rday_end.style.display="block"; txtday_end.style.display="block"; } else { txt1.style.display="none"; ryear_end.style.display="none"; txtyear_end.style.display="none"; rmonth_end.style.display="none"; txtmonth_end.style.display="none"; rday_end.style.display="none"; txtday_end.style.display="none"; }}//新建视图function newview(){ ViewComp.run("Login", username, password); if (ViewComp.getPropertyValueInt("LoggedIn")==0) { confirm("没有正确连接到数据库,请重新登陆或刷新页面!"); window.close(); return; } ViewComp.run("NewView");}//打开视图function openview(){ ViewComp.run("Login", username, password); if (ViewComp.getPropertyValueInt("LoggedIn")==0) { confirm("没有正确连接到数据库,请重新登陆或刷新页面!"); //alert("ErrorCode:"+ViewComp.getPropertyValueInt( "ErrorCode" )); window.close(); return; } ViewComp.run("LoadView");}//自定义视图function defineview(){ if (ViewComp == null) exit; ViewComp.run("SetDimension");}//保存视图function saveview(){ ViewComp.run("SaveViewAs");}//退出视图时的操作function unload(){ if (ViewComp == null) exit; ViewComp.run("disconnect");}function SetQA(){ //ViewComp.run("SetDimension", "销售相关指标", "A2", "0:销售金额");}//根据选择的维度进行数据过滤function SetDim(dim, pos, mems){ // makes the set dimension call and refreshes the display if (ViewComp == null) exit; ViewComp.run("SetDimension", dim, pos, mems); ViewComp.run("LoadData");}//只保留选择的itemfunction KeepOnly(txt, row, col){ // this implements a new feature in the product // when the user chooses a menu item for this feature // we set the dimension's selections to be the member that // the user clicked on - all other members are removed if (ViewComp == null) exit; ViewComp.setPropertyValueString("CurrentCellRow", row); ViewComp.setPropertyValueString("CurrentCellColumn", col); currcell = ViewComp.getPropertyValueString("CellContents"); currdim = ViewComp.getPropertyValueString("CellDimension"); celltype = ViewComp.getPropertyValueString("CellType"); if ((celltype == 0) || (celltype == 3)) exit; ViewComp.run("AddDimSelection", "1", currcell, "0", currdim); ViewComp.run("loaddata", 1);}//刷新view //Refreshes the data in the data access component applet and re-writes the data entry gridfunction onRefreshView(){ ViewComp.run("RefreshView");}//告警function setAlertValue(type){ if (type=='1'){ ViewComp.run ("TrafficLight", "计划", "hello"); }else{ ViewComp.run ("TrafficLight", "度量值", "hello"); } if (ViewComp.getPropertyValueInt( "ErrorCode" )=='17'){ alert("该项分析没有告警功能!"); } //ViewComp.run("TrafficLight");}//Sortfunction setSort(){ //alert(ViewComp.getPropertyValueString("CellContents",ViewComp.getPropertyValueInt("ColumnDimensionCount")-1,ViewComp.getPropertyValueInt("RowDimensionCount"))); //按照第一列排序,弹出对话框 ViewComp.run ("Sort", ViewComp.getPropertyValueInt("ColumnDimensionCount")-1, ViewComp.getPropertyValueInt("RowDimensionCount")); //与help文档不符,还不能自动选择,fuck //ViewComp.run ("Search", "度量值");//造成死机,不能用}function exit(){ return false;}//getViewDescfunction getViewDesc(){ return ViewComp.getPropertyValueString("ViewDescription");}//保存为htmlfunction saveAsHtml(){ ViewComp.run("ExportHTML");}//保存为Excelfunction saveAsExcel(){ //var a = ViewComp.getPropertyValueString("ViewName"); //var a = ViewComp.getPropertyValueString("CurrentDimension") //setPropertyValueString("CurrentDimension", int index) //setPropertyValueString("CurrentDimension", string dimensionName) columnCount = ViewComp.getPropertyValueInt("ViewColumnCount"); //alert("共" + columnCount + "列"); rowCount = ViewComp.getPropertyValueInt("ViewRowCount"); //alert("共" + rowCount + "行"); var ExcelApp = new ActiveXObject("Excel.Application"); ExcelApp.Visible = false; var ExcelSheet = new ActiveXObject("Excel.Sheet"); //var s = ""; for(i=0;i<rowCount;i++) { for(j=0;j<columnCount;j++) { hc = ViewComp.getPropertyValueString("CellHtmlColor",i,j); //s = s + hc; // b = ViewComp.getPropertyValueInt("CellColor",i,j); if (hc == "#ff0000") { ExcelSheet.ActiveSheet.Cells(i+2,j+1).Interior.ColorIndex = 3; } else if (hc == "#00ff00") { ExcelSheet.ActiveSheet.Cells(i+2,j+1).Interior.ColorIndex = 4; } else if (hc == "#0000ff") { ExcelSheet.ActiveSheet.Cells(i+2,j+1).Interior.ColorIndex = 5; } else if (hc == "#ffff00") { ExcelSheet.ActiveSheet.Cells(i+2,j+1).Interior.ColorIndex = 6; } ExcelSheet.ActiveSheet.Cells(i+2,j+1).value = ViewComp.getPropertyValueString("CellContents",i,j); } } //alert (s); vbDoExcel(ExcelSheet,columnCount); ExcelApp.Visible = true; filename = ExcelSheet.Application.GetSaveAsFilename("<%=ViewDesc%>.xls"); if (filename != false) { ExcelSheet.SaveAs(filename); alert("文件已经保存为\n" + filename); } //ExcelSheet.Application.Quit();}</script><SCRIPT LANGUAGE="VBScript">Function vbDoExcel(actsheet1,columnCount) Dim actsheet set actsheet = actsheet1.ActiveSheet dim range set range = actsheet.Range(actsheet.Cells(1,1), actsheet.Cells(1,columnCount + 1)) range.select range.Merge actsheet.Cells(1,1).Value = "<%=ViewDesc%>" range.Font.Name = "宋体" range.Font.Size = 22 actsheet.UsedRange.select actsheet.UsedRange.Columns.AutoFit set excel = nothingEnd Function</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -