📄 excelpage.aspx
字号:
var obj = tbs.get(i+'-'+ecol);
//tbobj.rows[obj.row].cells[obj.col].className = "righttd";
tbobj.rows[obj.row].cells[obj.col].style.borderRightColor = this.lineColor;
}
}
}
var selected_area = new selectedArea(null,null,'blue');
function getParentNodeByTagName(node,tagName)
{
while(node.tagName != tagName) node = node.parentElement;
return node;
}
function down()
{
selected_area.sy = event.y;
selected_area.ey = event.y;
n=1;
var scellobj = event.srcElement;
//ohoh2.innerText ="row:"+scellobj.parentElement.parentElement.rowIndex+",col:"+ scellobj.parentElement.cellIndex;
if(scellobj.parentElement.tagName == "TD")
{
selected_area.sobj = scellobj;//设置sobj和eobj
selected_area.eobj = scellobj;
selected_area.show();
//if(clickobj!=null)
// clickobj.style.width = "";
clickobj = scellobj;
//getinputwidth();
}
}
function up()
{
n=0;
}
function move()
{
selected_area.ey = event.y;
var ecellobj = event.srcElement;
if(n!=1) return;
if(ecellobj.parentElement.tagName == "TD")
{
selected_area.eobj = ecellobj;//设置eobj
selected_area.show();
}
}
function getFocusObj(kind,cellobj)
{
if(kind)
{
selected_area.sobj = cellobj;
}
selected_area.eobj = cellobj;
}
//获得单元格对象的坐标
function fnGetPosition(obj,direction)
{
var objPosition=0;
if(direction == "Left")
{
while (obj !=null){
objPosition+=obj["offsetLeft"];
obj=obj.offsetParent;
}
}
else if(direction == "Top")
{
while (obj !=null){
objPosition+=obj["offsetTop"];
obj=obj.offsetParent;
}
}
else if(direction == "Right")
{
var tdwidth = obj.offsetWidth;
while (obj !=null){
objPosition+=obj["offsetLeft"];
obj=obj.offsetParent;
}
objPosition += tdwidth;
}
else
{
var tdheight = obj.offsetHeight;
while (obj !=null){
objPosition+=obj["offsetTop"];
obj=obj.offsetParent;
}
objPosition += tdheight;
}
return objPosition;
}
//获得输入列的宽度
function getinputwidth()
{
if(clickobj!=null)
{
owidth = clickobj.offsetWidth;
oheight = clickobj.offsetHeight;
//胡耀2007-11-16号屏蔽
clickobj.style.width = owidth;//设置当前单元格样式
}
}
//接收键盘事件
document.onkeydown = function()
{
if(clickobj!=null)
{
if(clickobj.style.width == "")
getinputwidth();
}
if(window.event.keyCode==13)
{
tst();
window.event.keycode = 0;
window.event.returnValue = false;
}
else
{
/*if(clickobj == null)return;
var nw = clickobj.offsetWidth;
var pw = clickobj.parentElement.offsetWidth-3;
if(owidth < nw&&pw<nw)
{
//保持表的的宽度
tst();
//owidth = nw;
}*/
}
}
document.onkeyup = function()
{
GetMaxColRow(selected_area.geterow(),selected_area.getecol());//不是很正确
if(window.event.keyCode==13)
{
window.event.keycode = 0;
window.event.returnValue = false;
}
else
{
if(clickobj == null)return;
var nh = clickobj.offsetHeight;
//ohoh.innerText = oheight;
//ohoh1.innerText = nh;
if(oheight == nh)
{
return;
}
else
{
if(clickobj.parentElement.offsetHeight >= Number(nh)+2){oheight = nh;return;}
//改变两个表的高度
changeheight(nh-oheight);
oheight = nh;
//ohoh.innerText = oheight;
//ohoh1.innerText = nh
}
}
}
function tst()
{
if(clickobj==null)return;
var bak = clipboardData.getData('Text');
clipboardData.setData('Text','\n');
clickobj.focus();
document.execCommand('Paste');
clipboardData.setData('Text',bak);
var nh=clickobj.offsetHeight;
//ohoh.innerText = oheight;
//ohoh1.innerText = nh;
if(oheight==nh){return;}
else
{
if(clickobj.parentElement.offsetHeight >= Number(nh)+2){oheight = nh;return;}
//改变两个表的高度
changeheight(nh-oheight);
oheight = nh;
//ohoh.innerText = oheight;
//ohoh1.innerText = nh
}
}
function changeheight(h)
{
//h为增加的高度
var L = document.getElementById("lefttable");//MyHeadTab
var B = document.getElementById("tbobj");//MyBodyTab
var rows = clickobj.parentElement.rowSpan;
var addheight = parseFloat(h)/parseFloat(rows);
var rowindex = clickobj.parentElement.parentElement.rowIndex;//2007-10-15号改(-1)
for(var i=0 ;i<rows;i++)
{
//var obj = tbs.get(Number(rowindex+i)+'-'+0);
var h1 = B.rows[rowindex].cells[0].style.height.split('px')[0];
B.rows[rowindex].cells[0].style.height = parseFloat(h1) + parseFloat(addheight);
var h2 = L.rows[rowindex-1].cells[0].style.height.split('px')[0];
L.rows[rowindex-1].cells[0].style.height = parseFloat(h2) + parseFloat(addheight);
}
}
//************************拖动表头列宽******************************************
function HeadScroll()
{
document.getElementById("topdiv").scrollLeft = document.getElementById("rightdiv").scrollLeft;//THead,TBody
}
function ChangWidth()
{
var e = event.srcElement;
if (e == undefined)
return;
if (e.tagName != "TD")
return;
var H = document.getElementById("toptable");//MyHeadTab
var B = document.getElementById("tbobj");//MyBodyTab
var CellIndex;
for (var i = 0; i < H.rows(0).cells.length; i++)
if (H.rows(0).cells[i] == e)
{
CellIndex = i;
break;
}
CellIndex = i;
var l = e.offsetLeft;
if (e.style.cursor == "e-resize") //是改变列宽
{
e.setCapture();
document.onmousemove = function ()
{
if (e == undefined)
return;
e.style.cursor = "e-resize";
var w = event.x + document.body.scrollLeft - l-12;//getElementById("topdiv")
//ohoh.innerText = "hehe:"+w;
if (w >= 5)
{
e.style.width = w;
if (B.rows.length < 1)
return;
B.rows(0).cells[CellIndex].style.width = w-1;
/*if(typeof(Y) != "undefined")
clearTimeout(Y);
if (B.rows.length < 50) //防止排序有Bug
Y = setTimeout("ChangWidthx("+ CellIndex +","+w+")" , 100);
else
Y = setTimeout("ChangWidthx("+ CellIndex +","+w+")" , 800);*/
}
GetMaxColRow(0,CellIndex);
HeadScroll();
}
document.onmouseup = function ()
{
if (e == undefined)
return;
e.releaseCapture();
e = undefined;
}
}
else
{
return;
}
}
/*function ChangWidthx(CellIndex,w)
{
var B = document.getElementById("t1");//MyBodyTab
B.rows(0).cells[CellIndex].style.width = w-1;
HeadScroll();
}*/
function ChangCursor()
{
var e = event.srcElement;
if (e.tagName != "TD")
return;
var x = event.x + document.body.scrollLeft; //此值在固定表头时要更改getElementById("topdiv")
var l = e.offsetLeft;
var l=l + e.offsetWidth + addleft;
if (x >= l)
{
e.style.cursor = "e-resize";
}
else
e.style.cursor = "default";
}
//*********************************************************************************
//************************拖动表左行宽******************************************
function LeftScroll()
{
document.getElementById("leftdiv").scrollTop = document.getElementById("rightdiv").scrollTop;//THead,TBody
}
function ChangHeight()
{
var e = event.srcElement;
if (e == undefined)
return;
if (e.tagName != "TD")
return;
var L = document.getElementById("lefttable");//MyHeadTab
var B = document.getElementById("tbobj");//MyBodyTab
var CellIndex;
for (var i = 0; i < L.rows.length; i++)
if (L.rows(i).cells[0] == e)//获得事件行
{
CellIndex = i;
break;
}
CellIndex = i+1;
var l = e.offsetTop+addtop;//上一行到顶部的距离
if (e.style.cursor == "n-resize") //是改变行宽
{
e.setCapture();
document.onmousemove = function ()
{
if (e == undefined)
return;
e.style.cursor = "n-resize";
var w = event.y + document.body.scrollTop - l-6;//getElementById("topdiv"),12是鼠标的宽度
if (w >= 5)
{
e.style.height = w;//设置左边的高度
if (B.rows.length < 1)
return;
B.rows(CellIndex).cells[0].style.height = w;
}
GetMaxColRow(CellIndex,0);
HeadScroll();
}
document.onmouseup = function ()
{
if (e == undefined)
return;
e.releaseCapture();
e = undefined;
}
}
else
{
return;
}
}
/*function ChangHeighty(CellIndex,w)
{
var B = document.getElementById("t1");//MyBodyTab
B.rows(CellIndex).cells[0].style.height = w;
LeftScroll();
}*/
function ChangHCursor()
{
var e = event.srcElement;
if (e.tagName != "TD")
{
return;
}
var y = event.y + document.body.scrollTop; //此值在固定左表行时要更改getElementById("leftdiv")
var l = e.offsetTop;
var l=l + e.offsetHeight + addtop;
if (y >= l)
{
e.style.cursor = "n-resize";
}
else
e.style.cursor = "default";
}
//屏蔽右键菜单
if (document.all && window.print)
{
document.oncontextmenu = function() {return false;};
}
//打开文件
if('<%=open%>'=='y')
{
path.click();
var values = path.value;
if(values)
checkXMLDocObj(values);
}
//*********************************************************************************
//-->
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -