⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fcrep.js

📁 一个完整的
💻 JS
📖 第 1 页 / 共 5 页
字号:
//a1==>1,1
//strLbl="a1"
//返回一个包括行列的数组
    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
}

//**************************************************************************************
//调背景色部分
//2001-05-09 
//added by mq 
//**************************************************************************************
function SetColor(colorValue,iTag,iDefault){
//设置单元格的颜色,iTag=1则表示设置前景色,iDefault=0表示缺省
	//if (SetReadOnly()) return
	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()	
}

function DrawLine(iTag,sLineStyle){
//画线方法
//iTag=0-11
//sLineStyle="1px solid"
	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()
}

function funDrawHLine(rowno,linePx,strKey,iDelLine){
//画一条横线的函数,rowno是物理行号,linePx是线粗+实虚,strKey是指画那边线
//iDelLine=1表示删线
	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"
		}
	}
}
function funDrawVLine(colno,linePx,strKey,iDelLine){
//画一条竖线的函数,colno是物理列号,linePx是线粗+实虚,strKey是指画那边线
//iDelLine=1表示删线
	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"	
			}
		}
	}
}



//****end***********************************************************************************************
////////////////////////=======================================
//设置风格类
/*
function SetClassClick(oCur) {
//按钮按下去时的状态onmousedown
//	var s1=oCur.getAttribute("fcDown")
//	if (s1=="1")
		oCur.className="divmenuonclick"
//	else {
//		oCur.setAttribute("fcDown","0")
//		oCur.className="divmenuonclick"
//	}
}

function SetClassMenu(oCur) {
//正常状态onmouseup
	var s1=oCur.getAttribute("fcDown")
	if (s1=="1")
		oCur.className="divmenu"
	else
		oCur.className="divmenutrue"
		
}

function SetClassDown(oCur) {
//鼠标进入时状态onmouseover
	var s1=oCur.getAttribute("fcDown")
	if (s1=="1")
		oCur.className="divmenuonclick"
	else
		oCur.className="tblclassdown"
}
function SetClassUp(oCur) {
//鼠标离开后状态onmouseout
	var s1=oCur.getAttribute("fcDown")
	if (s1=="1")
		oCur.className="divmenutrue"
	else
		oCur.className="tblclassup"
}
*/
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()
}

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") {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -