复件 fcRep.js
资源名称:OA.rar [点击查看]
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:128k
源码类别:
OA系统
开发平台:
Java
- //2002.06.19 北京方成公司 梅勇
- //写隐藏div用于装表数据的备份
- document.write('<div id=tCopy style="DISPLAY: none; "></div>')
- //装入报表提示等待
- document.write('<div id=ShowWait style="BACKGROUND-COLOR: antiquewhite; COLOR: red; DISPLAY: none; FONT-SIZE: x-large; FONT-STYLE: normal; FONT-WEIGHT: bold; HEIGHT: 600px; LEFT:0px; position:absolute; TOP: 0px; WIDTH: 800px; Z-INDEX: 100"> 正在装入,请稍候...</div>')
- //装入用于开发的一排报表
- LoadButton()
- document.write('<TEXTAREA id=txt1 rows=3 style="DISPLAY: none; HEIGHT: 52px; LEFT: 132px; POSITION: absolute; TOP: 345px; WIDTH: 302px"></TEXTAREA>')
- var curKeyCode //用于webgrid中直接按键输入时运行timer时传递当前输入字符及原串
- var fc_wherexml="" //当前的XML条件串
- var fc_curpage=1 //当前页号
- var fc_allpages=1 //总页数
- //用于处理查询字段的输入和输出参数
- var sActFieldIn=""
- var sActFieldOut=""
- var blnMouseDown=false //在表格上mousedown时此变量为真
- //用于当移到边界外时捕获鼠标,自动滚动.
- var blnCapture=false
- var iTimeID=0
- var iTimeID1=0
- var iTimeID2=0
- var iTimeID3=0
- var tdEndSel //
- //---------------------
- //选择时,记录起止单元的坐标
- var sTop,sLeft,sWidth,sHeight,eTop,eLeft,eWidth,eHeight
- //记录选择时的起止单元格的物理位置
- var sRow,sCol,eRow,eCol
- //排好序后的位置
- var sRowSort,sColSort,eRowSort,eColSort
- //处于运行模式
- var blnRunMode=false
- //决定报表是否变化了
- var blnChange=false
- //不要运行表格的mouseup,thead_onclick时只运行在mousedown
- var NoRunMouseUp=false
- //当显示全部时要自动加行,将行数存此全局变量中
- var AutoAddLines=0
- //---------------------
- var lngUndo=-1
- var lngRedo=-1
- var oUndo
- oUndo=new ActiveXObject("Microsoft.XMLDOM")
- oUndo.async ="false";
- oUndo.loadXML("<root></root>")
- var oRedo
- oRedo=new ActiveXObject("Microsoft.XMLDOM")
- oRedo.async ="false";
- oRedo.loadXML("<root></root>")
- //---------------------
- var oFormula
- oFormula=new ActiveXObject("Microsoft.XMLDOM")
- oFormula.async ="false";
- oFormula.loadXML("<root></root>")
- var oGraph
- oGraph=new ActiveXObject("Microsoft.XMLDOM")
- oGraph.async ="false";
- oGraph.loadXML("<root></root>")
- //用于检查公式嵌套时ExpandFormula函数,传一个成功与失败的参数
- var bCheckFormula=false
- //保存公式嵌套错误信息的数组
- var arrCheckFormula=new Array()
- function ErrorFormula(sGetcell,sFormula,RC){
- this.sGetcell=sGetcell //"GETCELL(2,3)"
- this.sFormula=sFormula //"B2+B3"
- this.RC=RC //"C3"
- }
- /**
- *表格MOUSEDOWN事件处理,处理选择区域
- **/
- function t_onmousedown() {
- //show("t_onmousedown")
- var obj=event.srcElement
- if (event.button ==2)
- return;
- if(obj.tagName=="TD"){
- //alert(grid.ReadOnly)
- //如果只读
- var s1=obj.getAttribute("pressenter")
- if(grid.ReadOnly && s1==null){
- return
- }
- //-------
- if(t.rows(0).style.cursor=="default" && t.childNodes(0).childNodes(0).style.cursor=="default"){
- if(thead_onclick()){
- return
- }
- }
- }
- if(obj.id!="txtMyGrid"){
- if (obj.tagName!="TD" || obj.parentNode.rowIndex==0 || obj.cellIndex==0)
- return
- }
- //固定行上不能选择
- //if (blnFixRowDrap && obj.parentNode.rowIndex<lngFixRows) return
- //if (bShowMenu)
- showFontProperty(obj)
- blnMouseDown=true
- //if (t.rows(0).style.cursor =="move" || t.childNodes(0).childNodes(0).style.cursor =="move"){
- //}
- //else {
- if (blnCapture==false) {
- //show("Capture")
- blnCapture=true
- t.setCapture()
- }
- //}
- sLeft=obj.offsetLeft //初始位置
- sTop=obj.offsetTop
- sWidth=obj.offsetWidth
- sHeight=obj.offsetHeight
- if(t.style.borderLeftStyle=="none")
- sLeft++
- if(t.style.borderTopStyle=="none")
- sTop++
- eLeft=sLeft
- eTop=sTop
- eWidth=sWidth
- eHeight=sHeight
- var i
- //下面两个循环计算起始行列值
- var tmp=1
- for (i=0;i<=t.rows(0).cells.length-1;i++)
- {
- if(t.childNodes(0).childNodes(i).style.pixelWidth>0)
- tmp=tmp+t.childNodes(0).childNodes(i).style.pixelWidth
- if (tmp==sLeft)
- {
- sCol=i+1
- while (t.childNodes(0).childNodes(sCol).style.pixelWidth==0) {
- sCol=sCol+1
- if (sCol==t.rows(0).cells.length-1)
- break;
- }
- break;
- }
- }
- tmp=1
- for (i=0;i<t.rows.length;i++)
- {
- if (t.rows(i).style.display!="none")
- tmp=tmp+t.rows(i).style.pixelHeight
- if (tmp==sTop)
- {
- sRow=i+1
- while (t.rows(sRow).style.display=="none") {
- sRow=sRow+1
- if (sRow==t.rows.length-1)
- break;
- }
- break;
- }
- }
- //当选中一个合并单元时
- var arr=PhyToLog(sRow,sCol)
- var iRowSpan=t.rows(arr[0]).cells(arr[1]).rowSpan
- var iColSpan=t.rows(arr[0]).cells(arr[1]).colSpan
- eRow=sRow+iRowSpan-1
- eCol=sCol+iColSpan-1
- sRowSort=sRow
- sColSort=sCol
- eRowSort=eRow
- eColSort=eCol
- showBlueRect()
- showBlueScale(sRow,sCol,sRow,sCol)
- //先运行控件外的onmousedown
- var curObjTmp=event.srcElement
- if(curObjTmp.tagName!="TD") return
- if (curObjTmp.parentNode.rowIndex>0 && curObjTmp.cellIndex>0) {
- //if(typeof curObj=="undefined") curObj=curObjTmp
- try {
- grid.actcellchange(curObjTmp)
- }
- catch (e){}
- //curObj=curObjTmp
- //mcurRow=curObj.parentNode.rowIndex
- //mcurCol=curObj.cellIndex
- grid.moveedit(curObjTmp)
- }
- }
- /**
- *表格MOUSEMOVE事件处理,处理选择区域
- **/
- function t_onmousemove() {
- if (event.button ==2)
- return;
- if (blnMouseDown && grid.autosize==false) {
- if (event.y>grid.top+grid.height-17) {
- if (iTimeID==0) {
- iTimeID=window.setInterval("grid.Scroll(2)",200)
- }
- }
- else
- {
- if (iTimeID!=0) {
- window.clearInterval(iTimeID)
- }
- iTimeID=0
- }
- if (event.y<grid.top) {
- if (iTimeID1==0) {
- iTimeID1=window.setInterval("grid.Scroll(1)",200)
- }
- }
- else
- {
- if (iTimeID1!=0) {
- window.clearInterval(iTimeID1)
- }
- iTimeID1=0
- }
- if (event.x<=grid.left+35) {//35左边列宽
- if (iTimeID2==0) {
- iTimeID2=window.setInterval("grid.Scroll(3)",200)
- }
- }
- else
- {
- if (iTimeID2!=0) {
- window.clearInterval(iTimeID2)
- }
- iTimeID2=0
- }
- if (event.x>=grid.left+grid.width-17) {//17右边滚动条宽
- if (iTimeID3==0) {
- iTimeID3=window.setInterval("grid.Scroll(4)",200)
- }
- }
- else
- {
- if (iTimeID3!=0) {
- window.clearInterval(iTimeID3)
- }
- iTimeID3=0
- }
- }
- t.style.cursor="default"
- var obj=event.srcElement
- if (obj.tagName!="TD" || obj.parentNode.rowIndex==0 || obj.cellIndex==0)
- return
- if ( blnMouseDown==true){
- document.selection.clear()
- eLeft=obj.offsetLeft
- eTop=obj.offsetTop
- eWidth=obj.offsetWidth
- eHeight=obj.offsetHeight
- //show("sLeft="+sLeft+" sTop="+sTop+" sWidth="+sWidth+" sHeight="+sHeight
- //+" eLeft="+eLeft+" eTop="+eTop+" eWidth="+eWidth+" eHeight="+eHeight)
- tdEndSel=obj
- showBlueRect()
- }
- }
- /**
- *表格MOUSEUP事件处理,处理选择区域
- **/
- function t_onmouseup() {
- if(NoRunMouseUp) {
- NoRunMouseUp=false
- return
- }
- var bTmp=false
- blnMouseDown=false
- if (blnCapture) {
- if (iTimeID!=0) {
- window.clearInterval(iTimeID)
- bTmp=true
- }
- iTimeID=0
- if (iTimeID1!=0) {
- window.clearInterval(iTimeID1)
- bTmp=true
- }
- iTimeID1=0
- if (iTimeID2!=0) {
- window.clearInterval(iTimeID2)
- bTmp=true
- }
- iTimeID2=0
- if (iTimeID3!=0) {
- window.clearInterval(iTimeID3)
- bTmp=true
- }
- iTimeID3=0
- blnCapture=false
- t.releaseCapture()
- }
- var obj,iRow,iCol
- var bTmp=false
- if (event.button ==2)
- return;
- //当光标移到表外时,取mousemove保留的结尾选择单元格(tdEndSel)
- if (event.y>grid.top+t.offsetHeight || event.y<grid.top || event.x<=grid.left+35 || event.x>=grid.left+t.offsetWidth )
- obj=tdEndSel
- else
- obj=event.srcElement
- try{
- var sTest=obj.tagName
- }
- catch (e){
- obj=t.rows(0).cells(0)
- }
- if(obj.tagName=="TD"){
- //如果只读
- var s1=obj.getAttribute("pressenter")
- if(grid.ReadOnly && s1==null){
- return
- }
- }
- try {
- if (obj.tagName!="TD" || obj.cellIndex==0 || obj.parentNode.rowIndex==0 )
- return
- }
- catch (e){return}
- eLeft=obj.offsetLeft
- eTop=obj.offsetTop
- eWidth=obj.offsetWidth
- eHeight=obj.offsetHeight
- //计算列宽行高,用于计算起止点的物理位置.
- var i,j
- var tmp=1
- for (i=0;i<=t.rows(0).cells.length-1;i++)
- {
- if(t.childNodes(0).childNodes(i).style.pixelWidth>0) {
- tmp=tmp+t.childNodes(0).childNodes(i).style.pixelWidth
- }
- if (tmp==eLeft+eWidth)
- {
- eCol=i
- break;
- }
- }
- tmp=1
- for (i=0;i<t.rows.length;i++)
- {
- if (t.rows(i).style.display!="none")
- tmp=tmp+t.rows(i).style.pixelHeight
- if (tmp==eTop+eHeight)
- {
- eRow=i
- break;
- }
- }
- //show(sCol+" "+sRow+" "+eCol+" "+eRow)
- if(sRow>eRow){
- sRowSort=eRow
- eRowSort=sRow
- }
- else {
- sRowSort=sRow
- eRowSort=eRow
- }
- if(sCol>eCol){
- sColSort=eCol
- eColSort=sCol
- }
- else {
- sColSort=sCol
- eColSort=eCol
- }
- showBlueRect()
- showBlueScale(sRow,sCol,eRow,eCol)
- if(blnRunMode==false){
- if (cmdBrush.getAttribute("fcDown")=="1") {
- cmdPasteFormat()
- cmdBrush.setAttribute("fcDown","0")
- cmdBrush.className="tblclassup"
- clearBlueScale()
- }
- }
- }
- /**
- //表头点击处理
- **/
- function thead_onclick() {
- if (event.srcElement.tagName!="TD") return false
- var curColNo=event.srcElement.cellIndex
- var curRowNo=event.srcElement.parentNode.rowIndex
- if(curColNo==0 && curRowNo==0) {
- //点左上角
- selectRange(1,1,t.rows.length-1,t.rows(0).cells.length-1)
- NoRunMouseUp=true
- }
- else if(curRowNo==0) {
- //点第一列
- selectRange(1,curColNo,t.rows.length-1,curColNo)
- NoRunMouseUp=true
- }
- else if(curColNo==0){
- //点第一行
- selectRange(curRowNo,1,curRowNo,t.rows(0).cells.length-1)
- NoRunMouseUp=true
- }
- return NoRunMouseUp
- }
- /**
- *清除兰色的选中框
- **/
- function clearBlueScale(){
- tc.style.display ="none"
- for(var i=0;i<t.rows.length;i++)
- t.rows(i).cells(0).style.color="black"
- for(var j=0;j<t.rows(0).cells.length;j++)
- t.rows(0).cells(j).style.color="black"
- hideTxt()
- }
- /**
- *隐藏输入文本框
- **/
- function hideTxt(){
- txtMyGrid.style.display="none"
- }
- /**
- *显示兰色的选中框
- **/
- function showBlueScale(r0,c0,r1,c1){
- if(grid.ReadOnly) return
- //显示兰色的选中框
- var row0,col0,row1,col1 //物理位置
- //排序
- if (r1>r0){
- row0=r0
- row1=r1
- }
- else {
- row0=r1
- row1=r0
- }
- if (c1>c0){
- col0=c0
- col1=c1
- }
- else {
- col0=c1
- col1=c0
- }
- for (var i=0;i<t.rows.length;i++){
- if(i>=row0 && i<=row1 )
- t.rows(i).cells(0).style.color="blue"
- else
- t.rows(i).cells(0).style.color="black"
- }
- for (var i=0;i<t.rows(0).cells.length;i++){
- if(i>=col0 && i<=col1)
- t.rows(0).cells(i).style.color="blue"
- else
- t.rows(0).cells(i).style.color="black"
- }
- //显示框的背景色
- if (row0==row1 && col0==col1)//选中单个单元格
- tc.style.background ="white"
- else
- tc.style.background ="#e6e6fa"
- // if (lngStatus==3)//选中一个大的合并单元格
- // tc.style.background ="white"
- tc.style.display ="block"
- tc.style.zIndex =-1
- }
- /**
- *根据sLeft sTop sWidth sHeight eLeft eTop eWidth eHeight这八个全局变量的值计算兰框的位置
- **/
- function showBlueRect(){
- var curLeft,curTop,curWidth,curHeight
- /*
- var ssWidth,ssHeight
- if(sWidth>eWidth)
- ssWidth=sWidth
- else
- ssWidth=eWidth
- if(sHeight>eHeight)
- ssHeight=sHeight
- else
- ssHeight=eHeight
- */
- if (sLeft==eLeft && sTop==eTop) {
- curLeft=sLeft
- curTop=sTop
- curWidth=sWidth
- curHeight=sHeight
- }
- if (sLeft<=eLeft && sTop<=eTop)
- {
- curLeft=sLeft
- curTop=sTop
- curWidth=eWidth+eLeft-sLeft
- curHeight=eHeight+eTop-sTop
- }
- if (sLeft<=eLeft && sTop>eTop)
- {
- curLeft=sLeft
- curTop=eTop
- curWidth=eWidth+eLeft-sLeft
- curHeight=sHeight+sTop-eTop
- }
- if (sLeft>=eLeft && sTop>=eTop)
- {
- curLeft=eLeft
- curTop=eTop
- curWidth=sWidth+sLeft-eLeft
- curHeight=sHeight+sTop-eTop
- }
- if (sLeft>eLeft && sTop<=eTop)
- {
- curLeft=eLeft
- curTop=sTop
- curWidth=sWidth+sLeft-eLeft
- curHeight=eHeight+eTop-sTop
- }
- // tc.style.display ="block"
- // tc.style.zIndex =-1
- tc.style.left =curLeft
- tc.style.top =curTop
- tc.style.width =curWidth
- tc.style.height =curHeight
- }
- /**
- *选择某个区域的常用函数
- **/
- function selectRange(sRow1,sCol1,eRow1,eCol1){
- //
- sRow=sRow1
- sCol=sCol1
- eRow=eRow1
- eCol=eCol1
- if(sRow>eRow){
- sRowSort=eRow
- eRowSort=sRow
- }
- else {
- sRowSort=sRow
- eRowSort=eRow
- }
- if(sCol>eCol){
- sColSort=eCol
- eColSort=sCol
- }
- else {
- sColSort=sCol
- eColSort=eCol
- }
- showBlueScale(sRow,sCol,eRow,eCol)
- var arr=PhyToLog(sRow,sCol)
- var td1=t.rows(arr[0]).cells(arr[1])
- sLeft=td1.offsetLeft
- sTop=td1.offsetTop
- sWidth=td1.offsetWidth
- sHeight=td1.offsetHeight
- var arr1=PhyToLog(eRow,eCol)
- var td2=t.rows(arr1[0]).cells(arr1[1])
- eLeft=td2.offsetLeft
- eTop=td2.offsetTop
- eWidth=td2.offsetWidth
- eHeight=td2.offsetHeight
- showBlueRect()
- grid.moveedit(td1)
- }
- /**
- *单元格拆分
- **/
- function Split() {
- //show(sCol+" "+sRow+" "+eCol+" "+eRow)
- var lngStatus=SelStatus(sRow,sCol,eRow,eCol)
- if(lngStatus!=3) return
- //show(tCopy.innerHTML)
- var rCount=eRowSort-sRowSort+1 //合并的行数
- var cCount=eColSort-sColSort+1 //合并的列数
- //增加第一行之后的所有单元格
- for (var i=eRowSort;i>=sRowSort+1;i--){
- var tdsCol=PhyToLogCol(i,sColSort)
- //show("r="+i+" c="+sCol+" tdCol="+tdsCol)
- var tdeCol=eColSort-sColSort+tdsCol
- //show(tdeCol+" "+tdsCol)
- for (var j=tdsCol;j<=tdeCol;j++){
- if (tdsCol<t.rows(i).cells.length)
- t.rows(i).insertCell(tdsCol)
- else
- t.rows(i).insertCell()
- }
- }
- //增加第一行的第一个单元格之后的单元格
- var tdsCol=PhyToLogCol(sRowSort,sColSort)
- var tdeCol=eColSort-sColSort+tdsCol
- for (var j=tdsCol+1;j<=tdeCol;j++){
- if(tdsCol+1<t.rows(sRowSort).cells.length)
- t.rows(sRowSort).insertCell(tdsCol+1)
- else
- t.rows(sRowSort).insertCell()
- }
- //给第一单元格的rowSpan colSpan
- t.rows(sRowSort).cells(tdsCol).rowSpan=1
- t.rows(sRowSort).cells(tdsCol).colSpan=1
- CopytHtml()
- grid.moveedit()
- blnChange=true
- }
- /**
- *sRow sCol eRow eCol 单元格合并
- **/
- function Merge() {
- //
- //show(sCol+" "+sRow+" "+eCol+" "+eRow)
- var lngStatus=SelStatus(sRow,sCol,eRow,eCol)
- if(lngStatus!=4 ) return
- var rCount=eRowSort-sRowSort+1 //合并的行数
- var cCount=eColSort-sColSort+1 //合并的列数
- //删除第一行之后的所有单元格
- for (var i=eRowSort;i>=sRowSort+1;i--){
- var tdeCol=PhyToLogCol(i,eColSort)
- var tdsCol=PhyToLogCol(i,sColSort)
- for (var j=tdeCol;j>=tdsCol;j--){
- try {
- t.rows(i).deleteCell(j)
- }
- catch (e){}
- }
- }
- //删除第一行的第一个单元格之后的单元格
- var tdeCol=PhyToLogCol(sRowSort,eColSort)
- var tdsCol=PhyToLogCol(sRowSort,sColSort)
- for (var j=tdeCol;j>=tdsCol+1;j--){
- try {
- t.rows(sRowSort).deleteCell(j)
- }
- catch (e){}
- }
- //给第一单元格的rowSpan colSpan
- t.rows(sRowSort).cells(tdsCol).rowSpan=rCount
- t.rows(sRowSort).cells(tdsCol).colSpan=cCount
- CopytHtml()
- grid.moveedit()
- blnChange=true
- }
- function PhyToLog(row,col) {
- return PhyToLogTmp(row,col,1)
- }
- /**
- 求同一行物理列col的前面有多少个TD被合并了.然后返回col减去这个个数.
- 用于合并和拆分时找到删除TD和插入TD的位置
- **/
- function PhyToLogCol(row,col) {
- return PhyToLogTmp(row,col,3)
- }
- /**
- 物理位置-->逻辑位置(td位置)
- A:获得TD
- 找物理位置row,col,
- if物理位置row,col的单元格无tdCol属性
- 查找此行且小于此列共有多少个有tdCol属性的单元格,td位置=col-有tdCol属性的单元格个数
- 行为当前行.
- if物理位置row,col的单元格有tdCol属性,则td位置=tdCol,tdRow属性值
- **/
- function PhyToLogTmp(row,col,iType) {
- //中间函数
- //iType=1 返回TD, =2 返回TD对应的逻辑列col, =3返回单元格对应当前行所处的列位置,
- var t=tCopy.childNodes(0)
- var td_col=parseInt(t.rows(row).cells(col).getAttribute("tdCol"))
- var td_row=0
- var AddCols=0
- for(var j=0;j<col;j++){
- var tmp1=parseInt(t.rows(row).cells(j).getAttribute("tdCol"))
- if (isNaN(tmp1)==false)
- AddCols++
- }
- if (isNaN(td_col)) {
- td_col=col-AddCols
- td_row=row
- }
- else {
- if(iType==3){
- td_col=col-AddCols
- }
- td_row=parseInt(t.rows(row).cells(col).getAttribute("tdRow"))
- if(isNaN(td_row)) td_row=0 //属于意外
- }
- //
- if(iType==1) {
- //alert("row:"+td_row+"col:"+td_col)
- //return t.rows(td_row).cells(td_col)
- var arr=new Array()
- arr[0]=td_row
- arr[1]=td_col
- return arr
- //返回一个TD行列值组成的数组
- }
- if(iType==2 || iType==3)
- return td_col
- }
- /**
- 逻辑位置(td位置)-->物理位置 {此时行号是不变,只需求列号}
- A:一个单元格 B:一组单元格
- 找逻辑位置row,由小到大比较此行的列号和col(逻辑位置(td位置)),如单元格有tdCol属性则变量不加1,否则加1,
- 直到此变量等于col为至,此时当前单元格的列号即为物理位置的列号.
- 如是一组单元格则返回左上角单元格的列号
- **/
- function LogToPhy(row,col) {
- var colRet
- var AddCols=-1
- for(var j=0;j<tCopy.childNodes(0).rows(row).cells.length;j++){
- var tmp1=parseInt(tCopy.childNodes(0).rows(row).cells(j).getAttribute("tdCol"))
- if (isNaN(tmp1))
- AddCols++
- if(AddCols==col) {
- colRet=j
- break
- }
- }
- return colRet
- }
- /**
- 区域物理位置(sRow,sCol,eRow,eCol)-->判断:
- 0 意外,超出表格的行或列范围
- 1 一个单纯独立的单元格
- 2 一个合并单元格中的一部分
- 3 一个单纯的合并单元格
- 4 多个单纯独立的单元格组成的区域
- 5 整个合并单元格和小单元格组成的区域
- 直接输入或超链接:
- 一个小单元格/一个合并单元格
- 增删行列
- 一个小单元格
- 能合并
- 4多个小单元格组成的区域/5由整个合并单元加一些小单元格组成的区域
- 不能合并
- 一个小单元格/一个合并单元格/一个合并单元格的一部分
- 能拆分
- 3一个合并单元格
- 不能拆分
- NOT 一个合并单元格
- 设置字体等单元格属性
- 一个小单元格/一个合并单元格/多个小单元格组成的区域/由整个合并单元加一些小单元格组成的区域
- 在一个合并单元格的一部分+一些小单元格组成的区域情况下直接取单元格进行设置
- **/
- function SelStatus(sRow,sCol,eRow,eCol){
- //如果兰框未显示或行列超范围则返回0
- if(tc.style.display=="none" )
- return 0
- if(sRow==eRow && sCol==eCol) {
- return 1
- }
- var t=tCopy.childNodes(0)
- var colCount
- var rowCount=parseInt(t.rows(sRowSort).cells(sColSort).getAttribute("rowCount"))
- if(isNaN(rowCount)==false){
- colCount=parseInt(t.rows(sRowSort).cells(sColSort).getAttribute("colCount"))
- //show(rowCount+"=="+(eRowTmp-sRowTmp))
- if(rowCount-1==eRowSort-sRowSort && colCount-1==eColSort-sColSort){
- //只有一个合并单元格
- return 3
- }
- }
- //-------
- //判断区域中:包含整个合并单元/包含部分合并单元
- //如果合并单元格的主单元格在区域外,则肯定是包含部分合并单元
- //如果有一个合并单元格的主单元格+rowCount/+colCount超出区域的话,则肯定是包含部分合并单元
- var bMerge=false //是否有合并单元标志
- var bAllMerge=true //是否包含整个合并单元标志
- for(var i=sRowSort;i<=eRowSort;i++){
- for(var j=sColSort;j<=eColSort;j++){
- var rowCount=parseInt(t.rows(i).cells(j).getAttribute("rowCount"))
- if(isNaN(rowCount)==false){
- bMerge=true
- var colCount=parseInt(t.rows(i).cells(j).getAttribute("colCount"))
- if(i+rowCount-1>eRowSort || j+colCount-1>eColSort){
- bAllMerge=false
- }
- }
- var td_col=parseInt(t.rows(i).cells(j).getAttribute("tdCol"))
- if(isNaN(td_col)==false){
- var td_row=parseInt(t.rows(i).cells(j).getAttribute("tdRow"))
- if(td_row<sRowSort || td_row>eRowSort || td_col<sColSort || td_col>eColSort){
- //在区域外
- bAllMerge=false
- }
- bMerge=true
- }
- }
- }
- if(bMerge==false){ //一组小单元格
- return 4
- }
- if(bMerge){
- if (bAllMerge){
- //如果包含整个合并单元
- return 5
- }
- else {
- //包含部分合并单元
- return 2
- }
- }
- }
- //将物理位置-->逻辑位置(td位置)
- //td的列号,因行号相同
- /**计算方法:
- 将合并单元格按顺序展开,新加的单元格加一个tdCol属性用于标识此单元格对应的td位置.
- 物理位置-->逻辑位置(td位置)
- A:获得TD
- 找物理位置row,col,
- if物理位置row,col的单元格无tdCol属性
- 查找此行且小于此列共有多少个有tdCol属性的单元格,td位置=col-有tdCol属性的单元格个数
- 行为当前行.
- if物理位置row,col的单元格有tdCol属性,则td位置=tdCol,tdRow属性值
- 逻辑位置(td位置)-->物理位置 {此时行号是不变,只需求列号}
- A:一个单元格 B:一组单元格
- 找逻辑位置row,由小到大比较此行的列号和col(逻辑位置(td位置)),如单元格有tdCol属性则变量不加1,否则加1,
- 直到此变量等于col为至,此时当前单元格的列号即为物理位置的列号.
- *复制t.outerHTML
- **/
- function CopytHtml() {
- var s1=t.outerHTML
- s1=fc_RepStr(s1," id=t "," ")
- tCopy.innerHTML=s1
- ExpandTab(tCopy.childNodes(0))
- }
- /**
- *将合并单元格按顺序展开,新加的单元格加一个tdRow,tdCol属性用于标识此单元格对应的td位置.
- **/
- function ExpandTab(t) {
- // var d=new Date()
- // var t2=d.getTime()
- var curAddCell
- for (var i=0;i<t.rows.length ;i++) {
- for (var j=0;j<t.rows(i).cells.length ;j++) {
- var curTD=t.rows(i).cells(j)
- var lngRows=parseInt(curTD.rowSpan)
- if (isNaN(lngRows))lngRows=0
- var lngCols=parseInt(curTD.colSpan)
- if (isNaN(lngCols))lngCols=0
- if(lngCols>1 || lngRows>1 ) {
- var td_col=0
- var td_row=0
- td_col=parseInt(curTD.getAttribute("tdCol"))
- if(isNaN(td_col)==false) {
- //表示此单元格为一个生成的合并单元格
- td_row=parseInt(curTD.getAttribute("tdRow"))
- if (isNaN(td_row)) td_row=0 //属于意外
- }
- else {
- //原始合并单元加上如下属性
- curTD.setAttribute("rowCount",curTD.rowSpan)
- curTD.setAttribute("colCount",curTD.colSpan)
- //curTD.innerText="rC="+curTD.rowSpan+" cC="+curTD.colSpan
- //--------
- //因此行以前的合并格已展开,应减去
- var AddCols=0
- for(var jjj=0;jjj<=j;jjj++){
- var tmp1=parseInt(t.rows(i).cells(jjj).getAttribute("tdCol"))
- if (isNaN(tmp1)==false)
- AddCols++
- }
- td_col=j-AddCols
- td_row=i
- }
- }
- if (lngCols>1) {
- curTD.colSpan=1
- //补齐当前行的后面的单元
- for (var jjj=1;jjj<=lngCols-1;jjj++) {
- if (j>=t.rows(i).cells.length)
- curAddCell=t.rows(i).insertCell()//加到结尾
- else
- curAddCell=t.rows(i).insertCell(j+1)
- curAddCell.setAttribute("tdRow",td_row)
- curAddCell.setAttribute("tdCol",td_col)
- //curAddCell.innerText="R="+td_row+" C="+td_col
- curAddCell.innerText=curTD.innerText
- }
- }
- //rowSpan>1
- if (lngRows>1 ) {
- curTD.rowSpan=1
- //修改rowspan值,合并单元格下移
- var addCols=0
- //计算下一行同一列之前应缩小多少列
- for (var jjj=0;jjj<j; jjj++) {
- if(jjj>=t.rows(i+1).cells.length) break
- var c=parseInt(t.rows(i+1).cells(jjj).colSpan)
- if (isNaN(c)) c=1
- addCols=addCols+c-1
- }
- //if (i==2) alert("j="+j+" "+addCols)
- curAddCell=t.rows(i+1).insertCell(j-addCols)
- //生成的单元格应保存初始合并单元格的td row,col
- curAddCell.setAttribute("tdRow",td_row)
- curAddCell.setAttribute("tdCol",td_col)
- //curAddCell.innerText="R="+td_row+" C="+td_col
- curAddCell.innerText=curTD.innerText
- curAddCell.colSpan=lngCols
- curAddCell.rowSpan=lngRows-1
- //curAddCell.innerText="A"
- }
- } //列循环结束
- } //行循环结束
- // var d=new Date()
- // var t1=d.getTime()
- // alert(t1-t2)
- }
- function show(val) {
- txt1.style.display ="block"
- txt1.style.zIndex =2
- txt1.value =val
- }
- /**
- *向单元格给值时处理小数位数
- *curTD为要处理的单元格, v为要给的值
- **/
- function CellPoint(curTD,v) {
- var v1=parseFloat(v)
- if(isNaN(v1)==false){
- //小数位数
- var s1=curTD.getAttribute("pointnum")
- if(s1!=null){
- s1=parseInt(s1)
- curTD.innerText=ContDec(v1,s1)
- }
- else {
- curTD.innerText=v
- }
- }
- else {
- curTD.innerText=v
- }
- }
- //*****************************************************************************************
- //处理grid事件
- //*****************************************************************************************
- function grid_onVscroll() {
- if(tc.style.display=="block"){
- //show(sCol+" "+sRow+" "+eCol+" "+eRow)
- //此处暂时用物理位置,到时要变成逻辑位置
- var arr=PhyToLog(sRow,sCol)
- var arr1=PhyToLog(eRow,eCol)
- var tdStart=t.rows(arr[0]).cells(arr[1])
- var tdEnd=t.rows(arr1[0]).cells(arr1[1])
- //sLeft=tdStart.offsetLeft
- sTop=tdStart.offsetTop
- //sWidth=tdStart.offsetWidth
- sHeight=tdStart.offsetHeight
- //eLeft=tdEnd.offsetLeft
- eTop=tdEnd.offsetTop
- //eWidth=tdEnd.offsetWidth
- eHeight=tdEnd.offsetHeight
- //alert(sLeft+"=="+eLeft+" "+sTop+"=="+eTop)
- showBlueRect()
- }
- }
- function grid_onHscroll() {
- if(tc.style.display=="block"){
- //show(sCol+" "+sRow+" "+eCol+" "+eRow)
- //此处暂时用物理位置,到时要变成逻辑位置
- var arr=PhyToLog(sRow,sCol)
- var arr1=PhyToLog(eRow,eCol)
- var tdStart=t.rows(arr[0]).cells(arr[1])
- var tdEnd=t.rows(arr1[0]).cells(arr1[1])
- sLeft=tdStart.offsetLeft
- //sTop=tdStart.offsetTop
- sWidth=tdStart.offsetWidth
- //sHeight=tdStart.offsetHeight
- eLeft=tdEnd.offsetLeft
- //eTop=tdEnd.offsetTop
- eWidth=tdEnd.offsetWidth
- //eHeight=tdEnd.offsetHeight
- showBlueRect()
- }
- }
- /**
- *插入行
- **/
- function InsRow(){
- if(grid.ReadOnly) return
- if (tc.style.display =="none" ) return
- SaveoUndoOneRecord()
- var minRow
- if (sRow>eRow)
- minRow=eRow
- else
- minRow=sRow
- var iRows=Math.abs(eRow-sRow)
- MoveFormula(minRow,iRows+1,1)
- for(var i=0;i<=iRows;i++){
- // grid.InsertRow(minRow)
- //---------插入行
- var tdCount=0 //记录此行共要插多少个TD
- for (j=0;j<=t.rows(0).cells.length-1;j++){
- //i,minCol单元的坐标换成逻辑坐标找到TD,判断
- //如rowspan>1则i=i+rowspan-1,此TD的colspan>1则colspan=colspan-1,
- //如果colspan=1则删除此TD
- var arr=PhyToLog(minRow,j)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if(minRow==arr[0] || (curTD.rowSpan==1 && curTD.colSpan==1)){
- // alert(arr[0]+","+arr[1])
- //t.rows(minRow).insertCell()
- tdCount++
- }
- else { //从合并单元的半中间插入
- if(curTD.colSpan>1){
- j=j+curTD.colSpan-1
- }
- if(curTD.rowSpan>1){
- curTD.rowSpan=curTD.rowSpan+1
- }
- }
- }
- //按照计算好的TD个数插入行
- var oTr=t.insertRow(minRow)
- oTr.style.height=21
- for(j=0;j<tdCount;j++){
- t.rows(minRow).insertCell();
- }
- //---------
- }
- //理顺行标
- for (i=minRow;i<=t.rows.length-1;i++){
- t.rows(i).cells(0).innerText=i
- }
- // txtMyGrid.style.top=txtMyGrid.style.pixelTop-(iRows+1)*21 //per row height=21
- CopytHtml()
- var arr=PhyToLog(sRow,sCol)
- var moveTD=t.rows(arr[0]).cells(arr[1])
- grid.moveedit(moveTD)
- showBlueScale(sRow,sCol,eRow,eCol)
- //从单元属性中将公式及预处理过后的公式装入oFormula中
- LoadAllFormula()
- //强制表格宽高同步
- if(grid.autosize){
- grid.autosize=true
- }
- SaveoRedoOneRecord()
- blnChange=true
- }
- /**
- *删除行
- **/
- function DelRow(){
- if(grid.ReadOnly) return
- if (tc.style.display =="none" ) return
- //var lngStatus=SelStatus(sRow,sCol,eRow,eCol)
- //if(lngStatus==2 || lngStatus==5 ) return
- SaveoUndoOneRecord()
- var minRow
- if (sRow>eRow)
- minRow=eRow
- else
- minRow=sRow
- //如选择的兰框在最边上,则删除列后不再显示兰框
- if(eRow==t.rows.length-1 || sRow==t.rows.length-1 ){
- if(minRow==1){
- alert("不能全部删除!")
- return
- }
- }
- clearBlueScale()
- var iRows=Math.abs(eRow-sRow)
- MoveFormula(minRow,-(iRows+1),1)
- for(var i=0;i<=iRows;i++){
- // grid.DeleteRow(minRow)
- //---------列删除
- // t.children[0].removeChild(t.children[0].children[minCol])
- //固定行不能删除
- //if(t.childNodes(0).childNodes.length<=lngFixCols )return
- for (j=t.rows(0).cells.length-1;j>=0;j--){
- //i,minCol单元的坐标换成逻辑坐标找到TD,判断
- //如rowspan>1则i=i+rowspan-1,此TD的colspan>1则colspan=colspan-1,
- //如果colspan=1则删除此TD
- var arr=PhyToLog(minRow,j)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if(curTD.rowSpan==1 && curTD.colSpan==1){
- //
- t.rows(arr[0]).deleteCell(arr[1])
- }
- else {
- if(curTD.colSpan>1){
- j=j-curTD.colSpan+1
- }
- if(curTD.rowSpan>1){
- //alert(arr[0]+","+arr[1])
- //如当前单元是合并单元的主单元格则合并单元下移
- if (arr[0]==minRow){
- var tdNode=t.rows(arr[0]).cells(arr[1]).cloneNode(true)
- var iInsCol=PhyToLogCol(minRow+1,j)
- t.rows(minRow+1).insertCell(iInsCol)
- t.rows(minRow+1).cells(iInsCol).replaceNode(tdNode)
- t.rows(minRow+1).cells(iInsCol).rowSpan=curTD.rowSpan-1
- t.rows(arr[0]).deleteCell(arr[1])
- }
- else{
- curTD.rowSpan=curTD.rowSpan-1
- }
- }
- else if(curTD.rowSpan==1){
- t.rows(arr[0]).deleteCell(arr[1])
- }
- }
- }
- t.deleteRow(minRow)
- //-----------------
- }
- //理顺行标
- for (i=minRow;i<=t.rows.length-1;i++){
- t.rows(i).cells(0).innerText=i
- }
- CopytHtml()
- if(tc.style.display=="block"){
- var arr=PhyToLog(sRow,sCol)
- var moveTD=t.rows(arr[0]).cells(arr[1])
- grid.moveedit(moveTD)
- showBlueScale(sRow,sCol,eRow,eCol)
- }
- //从单元属性中将公式及预处理过后的公式装入oFormula中
- LoadAllFormula()
- //强制表格宽高同步
- if(grid.autosize){
- grid.autosize=true
- }
- SaveoRedoOneRecord()
- blnChange=true
- }
- /**
- *插入列
- **/
- function InsCol(){
- if(grid.ReadOnly) return
- if (tc.style.display =="none" ) return
- SaveoUndoOneRecord()
- var minCol
- if (sCol>eCol)
- minCol=eCol
- else
- minCol=sCol
- var iCols=Math.abs(eCol-sCol)
- MoveFormula(minCol,iCols+1)
- for(var i=0;i<=iCols;i++){
- // grid.InsertCol(minCol)
- //---------列插入
- var o=document.createElement("COL")
- o.style.width=70
- var iPos=t.childNodes(0).childNodes.length-1
- if (iPos>minCol)
- iPos=minCol
- t.children[0].insertBefore(o,t.children[0].children[iPos])
- //固定行不能删除
- //if(t.childNodes(0).childNodes.length<=lngFixCols )return
- for (j=0;j<=t.rows.length-1;j++){
- //i,minCol单元的坐标换成逻辑坐标找到TD,判断
- //如rowspan>1则i=i+rowspan-1,此TD的colspan>1则colspan=colspan-1,
- //如果colspan=1则删除此TD
- var arr=PhyToLog(j,minCol)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if(curTD.rowSpan==1 && curTD.colSpan==1){
- // alert(arr[0]+","+arr[1])
- t.rows(arr[0]).insertCell(arr[1])
- }
- else {
- if(curTD.rowSpan>1){
- j=j+curTD.rowSpan-1
- }
- if(curTD.colSpan>1){
- curTD.colSpan=curTD.colSpan+1
- }
- //else if(curTD.colSpan==1){
- // t.rows(arr[0]).deleteCell(arr[1])
- //}
- }
- }
- //-----------------
- }
- //理顺行标
- for (i=minCol;i<=t.rows(0).cells.length-1;i++){
- t.rows(0).cells(i).innerText=IntToLbl(i)
- }
- CopytHtml()
- var arr=PhyToLog(sRow,sCol)
- var moveTD=t.rows(arr[0]).cells(arr[1])
- grid.moveedit(moveTD)
- showBlueScale(sRow,sCol,eRow,eCol)
- //从单元属性中将公式及预处理过后的公式装入oFormula中
- LoadAllFormula()
- //强制表格宽高同步
- if(grid.autosize){
- grid.autosize=true
- }
- SaveoRedoOneRecord()
- blnChange=true
- }
- /**
- *删除列
- **/
- function DelCol(){
- if(grid.ReadOnly) return
- if (tc.style.display =="none" ) return
- //var lngStatus=SelStatus(1,sCol,t.rows.length-1,eCol)
- //alert(lngStatus)
- //if(lngStatus==2 || lngStatus==5 ) return
- SaveoUndoOneRecord()
- var minCol
- if (sCol>eCol)
- minCol=eCol
- else
- minCol=sCol
- //如选择的兰框在最边上,则删除列后不再显示兰框
- if(eCol==t.rows(0).cells.length-1 || sCol==t.rows(0).cells.length-1 ){
- if(minCol==1){
- alert("不能全部删除!")
- return
- }
- }
- clearBlueScale()
- var iCols=Math.abs(eCol-sCol)
- MoveFormula(minCol,-(iCols+1))
- for(var i=0;i<=iCols;i++){
- // grid.DeleteCol(minCol)
- //---------列删除
- t.children[0].removeChild(t.children[0].children[minCol])
- //固定行不能删除
- //if(t.childNodes(0).childNodes.length<=lngFixCols )return
- for (j=0;j<=t.rows.length-1;j++){
- //i,minCol单元的坐标换成逻辑坐标找到TD,判断
- //如rowspan>1则i=i+rowspan-1,此TD的colspan>1则colspan=colspan-1,
- //如果colspan=1则删除此TD
- var arr=PhyToLog(j,minCol)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if(curTD.rowSpan==1 && curTD.colSpan==1){
- // alert(arr[0]+","+arr[1])
- t.rows(arr[0]).deleteCell(arr[1])
- }
- else {
- if(curTD.rowSpan>1){
- j=j+curTD.rowSpan-1
- }
- if(curTD.colSpan>1){
- curTD.colSpan=curTD.colSpan-1
- }
- else if(curTD.colSpan==1){
- t.rows(arr[0]).deleteCell(arr[1])
- }
- }
- }
- //-----------------
- }
- //理顺行标
- for (i=minCol;i<=t.rows(0).cells.length-1;i++){
- t.rows(0).cells(i).innerText=IntToLbl(i)
- }
- CopytHtml()
- if(tc.style.display=="block"){
- var arr=PhyToLog(sRow,sCol)
- var moveTD=t.rows(arr[0]).cells(arr[1])
- grid.moveedit(moveTD)
- showBlueScale(sRow,sCol,eRow,eCol)
- }
- //从单元属性中将公式及预处理过后的公式装入oFormula中
- LoadAllFormula()
- //强制表格宽高同步
- if(grid.autosize){
- grid.autosize=true
- }
- SaveoRedoOneRecord()
- blnChange=true
- }
- /**
- * 1--->A由索引号取得字母
- **/
- function IntToLbl(colno){
- var strLbl="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- var inx=parseInt(colno/26)
- if (inx>26)
- return
- var strPrefix=strLbl.substring(inx-1,inx)
- var strColLbl=strLbl.substring(colno-inx*26-1,colno-inx*26)
- return strPrefix+strColLbl
- }
- /**
- * A--->1由字母取得索引号,只支持最大长度为2的strS
- **/
- function LblToInt(strC){
- var strLbl="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- var inx=strC.length
- var iCol
- if (inx==1)//一个字母
- iCol=strLbl.indexOf(strC)+1
- else//两个字母
- {
- iCol=(strLbl.indexOf(strC.substring(0,1))+1)*26+strLbl.indexOf(strC.substring(1,2))+1
- }
- return iCol
- }
- /**
- * a1==>1,1
- * strLbl="a1"
- * 返回一个包括行列的数组
- **/
- function TransAto1(strLbl){
- if(isSpace(strLbl)) return
- strLbl=trim(strLbl)
- var strChar,strInt
- var iLength=strLbl.length-1
- var iRow,iCol
- var lngA
- var dblR
- for (var i=0;i<=iLength;i++){
- lngA=parseInt(strLbl.charCodeAt(i))
- if (lngA>=49 && lngA<=57){
- var strChar=strLbl.substring(0,i)
- var strInt=strLbl.substring(i,iLength+1)
- break;
- }
- }
- iRow=parseInt(strInt)
- strChar=strChar.toUpperCase()
- iCol=parseInt(LblToInt(strChar))
- var sR=new Array(2)
- sR[0]=iRow
- sR[1]=iCol
- return sR;
- }
- /**
- *除去一节Style属性
- *strSource 为源Style属性串
- *strFind 为要除去的Style属性名
- *返回除去后的Style属性串
- **/
- function RemovePartStyle(strSource,strFind) {
- var strResult=""
- var arrS
- arrS=strSource.split(";")
- for (var i=0;i<arrS.length;i++) {
- var sUpper=arrS[i].toUpperCase()
- if (sUpper.indexOf(strFind.toUpperCase())==-1)
- strResult=strResult+arrS[i]+";"
- }
- return strResult
- }
- /**
- *设置单元格的颜色,iTag=1则表示设置前景色,iDefault=0表示缺省
- *@date 2001-05-09
- **/
- function SetColor(colorValue,iTag,iDefault){
- if (tc.style.display =="none")
- return
- SaveoUndoOneRecord()
- for (var i=sRowSort;i<=eRowSort;i++){
- for (var j=sColSort;j<=eColSort;j++){
- var arr=PhyToLog(i,j)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if(iTag==1){
- if(iDefault==0){
- //RemovePartStyle(curTD.style.cssText,"color")
- curTD.style.color="#000000"
- }
- else{
- curTD.style.color=colorValue
- }
- }
- else {
- if(iDefault==0)
- curTD.removeAttribute("bgColor")
- else
- curTD.bgColor=colorValue
- }
- //alert(curTD.style.color)
- }
- }
- blnChange=true
- hideTxt()
- SaveoRedoOneRecord()
- }
- /**
- *画线方法, iTag=0-11 sLineStyle="1px solid"
- **/
- function DrawLine(iTag,sLineStyle){
- if (iTag<0) return
- if (tc.style.display =="none")
- return
- SaveoUndoOneRecord()
- switch (iTag){
- case 0: //网格线
- for (var i=sRowSort-1;i<=eRowSort;i++)
- funDrawHLine(i,sLineStyle,"bottom")
- for (var i=sColSort-1;i<=eColSort;i++)
- funDrawVLine(i,sLineStyle,"right")
- break;
- case 1: //框线
- funDrawHLine(sRowSort,sLineStyle,"top")
- funDrawHLine(eRowSort,sLineStyle,"bottom")
- funDrawVLine(sColSort,sLineStyle,"left")
- funDrawVLine(eColSort,sLineStyle,"right")
- break;
- case 2: //上
- funDrawHLine(sRowSort,sLineStyle,"top")
- break;
- case 3: //下线
- funDrawHLine(eRowSort,sLineStyle,"bottom")
- break;
- case 4: //左
- funDrawVLine(sColSort,sLineStyle,"left")
- break;
- case 5: //右
- funDrawVLine(eColSort,sLineStyle,"right")
- break;
- case 6: //右斜线
- DrawVml();
- break;
- case 7: //网格线
- for (var i=sRowSort-1;i<=eRowSort;i++)
- funDrawHLine(i,sLineStyle,"bottom",1)
- for (var i=sColSort-1;i<=eColSort;i++)
- funDrawVLine(i,sLineStyle,"right",1)
- break;
- case 8: //框线
- funDrawHLine(sRowSort,sLineStyle,"top",1)
- funDrawHLine(eRowSort,sLineStyle,"bottom",1)
- funDrawVLine(sColSort,sLineStyle,"left",1)
- funDrawVLine(eColSort,sLineStyle,"right",1)
- break;
- case 9: //上
- funDrawHLine(sRowSort,sLineStyle,"top",1)
- break;
- case 10: //下线
- funDrawHLine(eRowSort,sLineStyle,"bottom",1)
- break;
- case 11: //左
- funDrawVLine(sColSort,sLineStyle,"left",1)
- break;
- case 12: //右
- funDrawVLine(eColSort,sLineStyle,"right",1)
- break;
- case 13: //右斜线
- DelDrawVml();
- break;
- }
- blnChange=true
- SaveoRedoOneRecord()
- }
- /**
- *画右斜线
- **/
- function DrawVml() {
- //画斜线
- if (tc.style.display =="none")
- return
- SaveoUndoOneRecord()
- var arr=PhyToLog(sRow,sCol)
- var curTD=t.rows(arr[0]).cells(arr[1])
- var oRect=curTD.getBoundingClientRect()
- var s1=(oRect.right-oRect.left-2)+"px,"+(oRect.bottom-oRect.top-2)+"px"
- curTD.innerHTML='<v:line id=line1 style="position:relative" from = "0,0" to = "'+s1+'">'
- blnChange=true
- hideTxt()
- SaveoRedoOneRecord()
- }
- /**
- *删除右斜线
- **/
- function DelDrawVml() {
- if (tc.style.display =="none")
- return
- SaveoUndoOneRecord()
- var arr=PhyToLog(sRow,sCol)
- var curTD=t.rows(arr[0]).cells(arr[1])
- curTD.innerHTML=''
- blnChange=true
- hideTxt()
- SaveoRedoOneRecord()
- }
- /**
- *画一条横线的函数,rowno是物理行号,linePx是线粗+实虚,strKey是指画那边线
- *iDelLine=1表示删线
- **/
- function funDrawHLine(rowno,linePx,strKey,iDelLine){
- var i
- for (i=sColSort;i<=eColSort;i++){
- var arr=PhyToLog(rowno,i)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if (strKey=="bottom"){
- if (iDelLine==1)
- curTD.style.cssText=RemovePartStyle(curTD.style.cssText,"border-Bottom")
- else
- curTD.style.borderBottom=linePx+" black"
- }
- else { //="top"
- //找到上一单元的下线画
- var arr1=PhyToLog(rowno-1,i)
- var curTD1=t.rows(arr1[0]).cells(arr1[1])
- if (iDelLine==1)
- curTD1.style.cssText=RemovePartStyle(curTD1.style.cssText,"border-Bottom")
- else
- curTD1.style.borderBottom=linePx+" black"
- }
- }
- }
- /**
- *画一条竖线的函数,colno是物理列号,linePx是线粗+实虚,strKey是指画那边线
- *iDelLine=1表示删线
- **/
- function funDrawVLine(colno,linePx,strKey,iDelLine){
- for (var i=sRowSort;i<=eRowSort;i++){
- var arr=PhyToLog(i,colno)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if (strKey=="right"){
- if (iDelLine==1)
- curTD.style.cssText=RemovePartStyle(curTD.style.cssText,"border-Right")
- else
- curTD.style.borderRight=linePx+" black"
- }
- else { //="left"
- if(colno==1){
- var arr1=PhyToLog(i,colno)
- var curTD1=t.rows(arr1[0]).cells(arr1[1])
- if (iDelLine==1)
- curTD1.style.cssText=RemovePartStyle(curTD1.style.cssText,"border-Left")
- else
- curTD1.style.borderLeft=linePx+" black"
- }
- else {
- //找到上一单元的下线画
- var arr1=PhyToLog(i,colno-1)
- var curTD1=t.rows(arr1[0]).cells(arr1[1])
- if (iDelLine==1)
- curTD1.style.cssText=RemovePartStyle(curTD1.style.cssText,"border-Right")
- else
- curTD1.style.borderRight=linePx+" black"
- }
- }
- }
- }
- /**
- *设置当前单元的字体
- *@param strKey :B,I,U,F,S
- **/
- function cmdFont(strKey)
- {
- // if (SetReadOnly()) return
- if (tc.style.display =="none")
- return
- // var i,j
- // var sColno,eColno
- SaveoUndoOneRecord()
- // MatchRowCol()
- // getColnoPerRow()
- //选中单个的单元格的情况
- var i,j
- var sB=cmdFontBold.getAttribute("fcDown")
- var sI=cmdFontItalic.getAttribute("fcDown")
- var sU=cmdFontU.getAttribute("fcDown")
- if (sB=="1") {
- cmdFontBold.setAttribute("fcDown","0")
- }
- else {
- cmdFontBold.setAttribute("fcDown","1")
- }
- if (sI=="1") {
- cmdFontItalic.setAttribute("fcDown","0")
- }
- else {
- cmdFontItalic.setAttribute("fcDown","1")
- }
- if (sU=="1") {
- cmdFontU.setAttribute("fcDown","0")
- }
- else {
- cmdFontU.setAttribute("fcDown","1")
- }
- for (i=sRowSort;i<=eRowSort;i++)
- {
- for (j=sColSort;j<=eColSort;j++)
- {
- var arr=PhyToLog(i,j)
- var curTD=t.rows(arr[0]).cells(arr[1])
- switch (strKey){
- case "B":
- if (sB=="1") {
- curTD.style.fontWeight="normal"
- }
- else {
- curTD.style.fontWeight="bold"
- }
- break;
- case "I":
- if (sI=="1") {
- curTD.style.fontStyle="normal"
- }
- else {
- curTD.style.fontStyle="italic"
- }
- break;
- case "U":
- if (sU=="1") {
- curTD.style.textDecorationUnderline=false
- }
- else {
- curTD.style.textDecorationUnderline=true
- }
- break;
- case "F":
- curTD.style.fontFamily=cboFont.options[cboFont.selectedIndex].text
- break;
- case "S":
- curTD.style.fontSize=cboFontSize.options[cboFontSize.selectedIndex].text
- break;
- }
- }
- }
- blnChange=true
- hideTxt()
- SaveoRedoOneRecord()
- }
- /**
- *处理当前单元格的对齐
- *@param strAlign:left,center,right,top,middle,bottom
- *@param strOrient:h v
- **/
- function cmdAlign(strAlign,strOrient)
- {
- //if (SetReadOnly()) return
- //var sColno,eColno
- if (tc.style.display =="none")
- return
- //判断按钮是按下还是恢复。
- var blnPressDown=true
- if((strAlign=="left" && cmdLeft.getAttribute("fcDown")=="1")
- || (strAlign=="center" && cmdCenter.getAttribute("fcDown")=="1")
- || (strAlign=="right" && cmdRight.getAttribute("fcDown")=="1")
- || (strAlign=="top" && cmdTopv.getAttribute("fcDown")=="1")
- || (strAlign=="middle" && cmdMiddle.getAttribute("fcDown")=="1")
- || (strAlign=="bottom" && cmdBottomv.getAttribute("fcDown")=="1")
- )
- blnPressDown=false
- //MatchRowCol()
- // getColnoPerRow()
- //选中单个的单元格的情况
- SaveoUndoOneRecord()//在改变之前保存住位置,备undo时装入
- var i,j
- for (i=sRowSort;i<=eRowSort;i++){
- for (j=sColSort;j<=eColSort;j++){
- var arr=PhyToLog(i,j)
- var curTD=t.rows(arr[0]).cells(arr[1])
- if (strOrient=="h") {
- if (strAlign=="left") {
- if (blnPressDown==false) {
- cmdLeft.setAttribute("fcDown","0")
- curTD.align=""
- }
- else {
- cmdLeft.setAttribute("fcDown","1")
- cmdCenter.setAttribute("fcDown","0")
- cmdRight.setAttribute("fcDown","0")
- cmdCenter.className="tblclassup"
- cmdRight.className="tblclassup"
- curTD.align="left"
- }
- }
- if (strAlign=="center") {
- if (blnPressDown==false) {
- cmdCenter.setAttribute("fcDown","0")
- curTD.align=""
- }
- else {
- cmdLeft.setAttribute("fcDown","0")
- cmdCenter.setAttribute("fcDown","1")
- cmdRight.setAttribute("fcDown","0")
- cmdLeft.className="tblclassup"
- cmdRight.className="tblclassup"
- curTD.align="center"
- }
- }
- if (strAlign=="right") {
- if (blnPressDown==false) {
- cmdRight.setAttribute("fcDown","0")
- curTD.align=""
- }
- else {
- cmdLeft.setAttribute("fcDown","0")
- cmdCenter.setAttribute("fcDown","0")
- cmdRight.setAttribute("fcDown","1")
- cmdLeft.className="tblclassup"
- cmdCenter.className="tblclassup"
- curTD.align="right"
- }
- }
- }
- if (strOrient=="v") {
- if (strAlign=="top") {
- if (blnPressDown==false) {
- cmdTopv.setAttribute("fcDown","0")
- curTD.vAlign=""
- }
- else {
- cmdTopv.setAttribute("fcDown","1")
- cmdMiddle.setAttribute("fcDown","0")
- cmdBottomv.setAttribute("fcDown","0")
- cmdMiddle.className="tblclassup"
- cmdBottomv.className="tblclassup"
- curTD.vAlign="top"
- }
- }
- if (strAlign=="middle") {
- if (blnPressDown==false) {
- cmdMiddle.setAttribute("fcDown","0")
- curTD.vAlign=""
- }
- else {
- cmdTopv.setAttribute("fcDown","0")
- cmdMiddle.setAttribute("fcDown","1")
- cmdBottomv.setAttribute("fcDown","0")
- cmdTopv.className="tblclassup"
- cmdBottomv.className="tblclassup"
- curTD.vAlign="middle"
- }
- }
- if (strAlign=="bottom") {
- if (blnPressDown==false) {
- cmdMiddle.setAttribute("fcDown","0")
- curTD.vAlign=""
- }
- else {
- cmdTopv.setAttribute("fcDown","0")
- cmdMiddle.setAttribute("fcDown","0")
- cmdBottomv.setAttribute("fcDown","1")
- cmdTopv.className="tblclassup"
- cmdMiddle.className="tblclassup"
- curTD.vAlign="bottom"
- }
- }
- }
- }
- }
- blnChange=true
- hideTxt()
- SaveoRedoOneRecord() //在改变之后保存住位置,备redo时装入
- }
- /**
- *当在某单元格时,处理工具栏的显示状态
- **/
- function showFontProperty(tdobj){
- if(blnRunMode)return
- if (tdobj.align=="left") {
- cmdLeft.setAttribute("fcDown","1")
- cmdLeft.className="divmenutrue"
- }
- else {
- cmdLeft.setAttribute("fcDown","0")
- cmdLeft.className="tblclassup"
- }
- if (tdobj.align=="center") {
- cmdCenter.setAttribute("fcDown","1")
- cmdCenter.className="divmenutrue"
- }
- else {
- cmdCenter.setAttribute("fcDown","0")
- cmdCenter.className="tblclassup"
- }
- if (tdobj.align=="right") {
- cmdRight.setAttribute("fcDown","1")
- cmdRight.className="divmenutrue"
- }
- else {
- cmdRight.setAttribute("fcDown","0")
- cmdRight.className="tblclassup"
- }
- if (tdobj.vAlign=="top") {
- cmdTopv.setAttribute("fcDown","1")
- cmdTopv.className="divmenutrue"
- }
- else {
- cmdTopv.setAttribute("fcDown","0")
- cmdTopv.className="tblclassup"
- }
- if (tdobj.vAlign=="middle") {
- cmdMiddle.setAttribute("fcDown","1")
- cmdMiddle.className="divmenutrue"
- }
- else {
- cmdMiddle.setAttribute("fcDown","0")
- cmdMiddle.className="tblclassup"
- }
- if (tdobj.vAlign=="bottom") {
- cmdBottomv.setAttribute("fcDown","1")
- cmdBottomv.className="divmenutrue"
- }
- else {
- cmdBottomv.setAttribute("fcDown","0")
- cmdBottomv.className="tblclassup"
- }
- //跟踪B I U
- if (tdobj.style.fontWeight=="bold") {
- cmdFontBold.setAttribute("fcDown","1")
- cmdFontBold.className="divmenutrue"
- }
- else {
- cmdFontBold.setAttribute("fcDown","0")
- cmdFontBold.className="tblclassup"
- }
- if (tdobj.style.fontStyle=="italic") {
- cmdFontItalic.setAttribute("fcDown","1")
- cmdFontItalic.className="divmenutrue"
- }
- else {
- cmdFontItalic.setAttribute("fcDown","0")
- cmdFontItalic.className="tblclassup"
- }
- if (tdobj.style.textDecorationUnderline==true) {
- cmdFontU.setAttribute("fcDown","1")
- cmdFontU.className="divmenutrue"
- }
- else {
- cmdFontU.setAttribute("fcDown","0")
- cmdFontU.className="tblclassup"
- }
- var strFont=tdobj.style.fontFamily
- var lngFontSize=parseInt(tdobj.style.fontSize)
- switch(strFont) {
- case "宋体":
- cboFont.selectedIndex =0
- break;
- case "仿宋_GB2312":
- cboFont.selectedIndex =1
- break;
- case "黑体":
- cboFont.selectedIndex =2
- break;
- case "楷体_GB2312":
- cboFont.selectedIndex =3
- break;
- case "隶书":
- cboFont.selectedIndex =4
- break;
- case "幼圆":
- cboFont.selectedIndex =5
- break;
- case "Arial":
- cboFont.selectedIndex =6
- break;
- case "Courier":
- cboFont.selectedIndex =7
- break;
- default:
- cboFont.selectedIndex =0
- break;
- }
- switch(lngFontSize) {
- case 4:
- cboFontSize.selectedIndex =0
- break;
- case 6:
- cboFontSize.selectedIndex =1
- break;
- case 8:
- cboFontSize.selectedIndex =2
- break;
- case 9:
- case 10:
- case 11:
- case 12:
- cboFontSize.selectedIndex =lngFontSize - 6
- break;
- case 14:
- cboFontSize.selectedIndex =7
- break;
- case 16:
- cboFontSize.selectedIndex =8
- break;
- case 18:
- cboFontSize.selectedIndex =9
- break;
- case 20:
- cboFontSize.selectedIndex =10
- break;
- case 22:
- cboFontSize.selectedIndex =11
- break;
- case 24:
- cboFontSize.selectedIndex =12
- break;
- case 26:
- cboFontSize.selectedIndex =13
- break;
- case 28:
- cboFontSize.selectedIndex =14
- break;
- case 36:
- cboFontSize.selectedIndex =15
- break;
- case 48:
- cboFontSize.selectedIndex =16
- break;
- case 72:
- cboFontSize.selectedIndex =17
- break;
- default:
- cboFontSize.selectedIndex =8
- break;
- }
- //show(tdobj.bgColor)
- if(isSpace(tdobj.bgColor)){
- sel1.selectedIndex=0
- }
- else {
- for(var i=1;i<sel1.options.length;i++){
- if(sel1.options(i).style.backgroundColor==tdobj.bgColor){
- sel1.selectedIndex=i
- break
- }
- }
- }
- if(isSpace(tdobj.style.color)){
- sel2.selectedIndex=0
- }
- else {
- for(var i=1;i<sel2.options.length;i++){
- if(sel2.options(i).style.backgroundColor==tdobj.style.color){
- sel2.selectedIndex=i
- break
- }
- }
- }
- }
- /**
- *用于点击了工具栏上的按钮后将焦点给到文本框上
- **/
- function ExitMe() {
- window.setTimeout("try {txtMyGrid.focus()} catch (e){}", 10);
- }
- /**
- *初始化表格以外的东西:滚动条,div的边框,运行时显示的按钮等
- *用于打开一个表将这些东西调动后(用进入时运行事件)又打开一个表时恢复
- **/
- function InitOutTable() {
- t.parentNode.style.borderLeft="1px solid";
- t.parentNode.style.borderRight="1px solid";
- t.parentNode.style.borderTop="1px solid";
- t.parentNode.style.borderBottom="1px solid";
- grid.hideHscroll=false;
- grid.hideVscroll=false;
- t.parentNode.style.backgroundImage="";
- t.parentNode.style.backgroundColor="";
- fcPage.style.display="none"
- fcShowAll.style.display="none"
- for(var i=0;i<5;i++){fcButton[i].style.display="none"}
- txtMyGrid.style.display="none"
- tc.style.display="none"
- fc_curpage=1
- fc_allpages=1
- }
- /**
- *保存报表
- **/
- function SaveReport() {
- t.setAttribute("graph",escape(oGraph.documentElement.xml))
- CopytHtml()
- var s1=document.title
- if(isSpace(s1)){
- //新增存盘
- var sRet=window.showModalDialog("input.htm",s1,"status:no;dialogHeight:120px;dialogWidth:400px;dialogTop:180;dialogLeft:250px")
- if(typeof sRet=="undefined") return
- var s2=SqlToField("select fstrTableName from fcCell where fstrTableName='"+escape(sRet)+"'")
- if(s2!=""){
- alert("报表名称:"+sRet+"的报表已存在,请另取一个报表名称。")
- return
- }
- var sql="Insert into fcCell (fstrTableName,fstrTable,fstrTable1) values ('"+escape(sRet)+"','"+escape(t.outerHTML)+"','"+escape(tCopy.innerHTML)+"')"
- document.title=sRet
- if(fc_Database=="access")
- var sR=fc_insert(sql)
- else
- var sR=fc_insertClob(sql)
- }
- else {
- //修改存盘
- var sql="Update fcCell set fstrTable='"+escape(t.outerHTML)+"',fstrTable1='"+escape(tCopy.innerHTML)+"' Where fstrTableName='"+escape(s1)+"'"
- if(fc_Database=="access")
- var sR=fc_insert(sql)
- else
- var sR=fc_updateClob(sql)
- }
- if(isSpace(sR)){
- alert("保存成功!")
- }
- else{
- alert(sR)
- }
- blnChange=false
- }
- /**
- *报表另存
- **/
- function SaveAsReport() {
- t.setAttribute("graph",escape(oGraph.documentElement.xml))
- CopytHtml()
- var sRet=window.showModalDialog("input.htm","","status:no;dialogHeight:120px;dialogWidth:400px;dialogTop:180;dialogLeft:250px")
- if(typeof sRet=="undefined") return
- var s2=SqlToField("select fstrTableName from fcCell where fstrTableName='"+escape(sRet)+"'")
- if(s2!=""){
- alert("报表名称:"+sRet+"的报表已存在,请另取一个报表名称。")
- return
- }
- var sql="Insert into fcCell (fstrTableName,fstrTable,fstrTable1) values ('"+escape(sRet)+"','"+escape(t.outerHTML)+"','"+escape(tCopy.innerHTML)+"')"
- var sR=fc_insert(sql)
- if(isSpace(sR)){
- document.title=sRet
- alert("保存成功!")
- }
- else{
- alert(sR)
- }
- blnChange=false
- }
- /**
- *新增一张报表,先检查是否要保存当前报表
- **/
- function NewReport() {
- CheckReportChange()
- var sTab='<TABLE borderColor=lightgrey borderColorDark=white cellPadding=0 cellSpacing=0 frame=box id=t style="BORDER-COLLAPSE: collapse; BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; CURSOR: default; FILTER: alpha(opacity=90);TABLE-LAYOUT: fixed; POSITION: absolute; LEFT: 0px; TOP: 0px" '
- +'onmousedown="t_onmousedown()" onmousemove="t_onmousemove()" onmouseup="t_onmouseup()" >'
- +'<COLGROUP id=tg><COL style="width:35" align=middle class=fixedStyle><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"><COL style="width:70"></COLGROUP>'
- +'<THEAD><TR style="height:21" align=middle class=fixedStyle ><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD><TD>G</TD><TD>H</TD><TD>I</TD><TD>J</TD></TR></THEAD>'
- +'<TBODY>'
- +'<TR style="height:21"><TD>1</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR>'
- +'<TR style="height:21"><TD>2</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>3</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>4</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>5</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>6</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>7</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>8</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>9</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>10</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>11</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>12</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>13</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>14</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>15</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>16</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>17</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>18</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>19</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>20</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>21</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>22</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>23</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD>24</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="height:21"><TD >25</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR>'
- +'</TBODY></TABLE>'
- t.outerHTML=sTab
- CopytHtml()
- document.title=""
- grid.reload(sTab)
- initoUndooRedo()
- oFormula=new ActiveXObject("Microsoft.XMLDOM")
- oFormula.async ="false";
- oFormula.loadXML("<root></root>")
- oGraph=new ActiveXObject("Microsoft.XMLDOM")
- oGraph.async ="false";
- oGraph.loadXML("<root></root>")
- blnChange=false
- }
- function LoadReport(TableName,sFilter) {
- //TableName为打开的报表名称。
- //sFilter为联查报表时的过滤条件串
- //先检查是否要保存当前报表
- //show("aaa")
- CheckReportChange()
- ShowWait.style.display="block";
- if(fc_Database=="access"){
- var sql="select fstrTable from fcCell Where fstrTableName='"+escape(TableName)+"'"
- var sTab=unescape(SqlToField(sql))
- t.outerHTML=sTab
- CopytHtml()
- }else {
- var sTab=unescape(fc_loadClob("<no>"+escape(TableName)+"</no>"))
- var sTab1=unescape(fc_loadClob1("<no>"+escape(TableName)+"</no>"))
- //去掉id=t
- sTab1=fc_RepStr(sTab1," id=t "," ")
- tCopy.innerHTML=sTab1
- t.outerHTML=sTab
- }
- document.title=TableName
- grid.reload(sTab)
- InitOutTable()
- //----------------------
- initoUndooRedo()
- LoadAllFormula()
- // oGraph=new ActiveXObject("Microsoft.XMLDOM")
- // oGraph.async ="false";
- // oGraph.loadXML("<root></root>")
- // LoadGraph(1)
- // setGraph(1)
- queryToolbar.style.display="none"
- //装入运行时的设置参数
- if(blnRunMode) {
- //查询SQL
- queryToolbar.style.display="block"
- initButton()
- var s1=t.getAttribute("queryorder")
- if(s1=="1" && arguments.length==1){
- //直接出查询条件对话框
- fc_wherexml="" //清空条件变量
- fc_getwhere()
- }
- else {
- //LoadWhereToSql()
- //用于打开统计表时,需要装入缺省条件进行查询
- if (arguments.length==2){
- fc_wherexml=sFilter
- }
- else {
- if(isSpace(t.getAttribute("initwhere")))
- fc_wherexml=""
- else
- fc_wherexml=t.getAttribute("initwhere")
- }
- fc_wherexml=unescape(fc_wherexml)
- fc_curpage=1
- fc_executesql(1,fc_wherexml)//1 为页号,fc_wherexml为条件数据的XML串
- //-----------------------------------
- }
- var arySend=t.getAttribute("runpara")
- if(arySend!=null){
- eval(unescape(arySend))
- }
- }
- //当外部是自动表格尺寸时
- if (grid.autosize){
- grid.hideVscroll=true
- grid.hideHscroll=true
- grid.autosize=true
- }
- //----------------------
- //运行模式中的参数内容:
- /*
- 隐藏行标列标和边框:
- t.rows(0).style.display="none";
- t.childNodes(0).childNodes(0).style.pixelWidth=0;
- t.border=0;
- t.style.borderLeft="";
- t.style.borderRight="";
- t.style.borderTop="";
- t.style.borderBottom="";
- 隐藏滚动条:
- grid.hideVscroll=true;
- grid.hideHscroll=true;
- 不能修改行高列宽
- grid.AdjustRowHeight=false;
- grid.AdjustColWidth=false;
- 只读
- (不能增删行增删列,除设了回车键后移动到何单元此属性之外的单元(不能录入和点击进入),不出现兰框
- grid.ReadOnly=true;
- 在固定列上能否拖动修改
- */
- //----------------------
- blnChange=false
- window.setTimeout("ShowWait.style.display='none';", 10);
- }
- /**
- *打印报表
- **/
- function PrintReport(){
- grid.prn.inPrint=1
- grid.print()
- }
- /**
- *打印预览报表
- **/
- function PreviewReport() {
- grid.prn.inPrint=0
- grid.print()
- }
- /**
- *块复制
- **/
- function cmdBlockCopy(){
- if (tc.style.display =="none")
- return
- //检查区域是否有合并的单元格
- /* if (lngStatus==3 || lngStatus==4){
- alert("选择的区域内有合并单元格,不能做块复制!")
- return
- }
- */
- //块复制
- var i,j,clipboard=""
- //var sColno,eColno
- //blockObjAry=new Array()
- //blockObjAry[0]=eRowSort-sRowSort
- //blockObjAry[1]=eColSort-sColSort
- //var inx=2
- for (i=sRowSort;i<=eRowSort;i++){
- /*
- sColno=sCol
- eColno=eCol
- var osFind=oCoor.documentElement.selectNodes("//record[row='" + i + "' and col='" +sCol +"']")
- if (osFind.length>=1)
- sColno=parseInt(osFind.item(0).childNodes.item(2).text)
- var osFind=oCoor.documentElement.selectNodes("//record[row='" + i + "' and col='" +eCol +"']")
- if (osFind.length>=1)
- eColno=parseInt(osFind.item(0).childNodes.item(2).text)
- */
- for (j=sColSort;j<=eColSort;j++){
- var arr=PhyToLog(i,j)
- var curTD=t.rows(arr[0]).cells(arr[1])
- // blockObjAry[inx]=curTD.innerText //curTD.cloneNode(true)
- clipboard=clipboard+curTD.innerText+"t"
- // inx=inx+1
- }
- clipboard=clipboard+"n"
- }
- window.clipboardData.setData("Text",clipboard)
- }
- /**
- *块粘贴
- **/
- function cmdBlockPaste(){
- //if (SetReadOnly()) return
- var clipboard=""