Namespace.register("U.Excel"); U.Excel.TF = { "ID": { "RW": [[]], "TF": [[40, 20]], "Cell": [[]], "L": [[]], "T": [[]] } }; //数据库变量 原始变量 U.Excel.SY = { "UW": window, "OL": true, "userid": "", "TF": [], "BC": false, "ID": "", "CP": [], "TD": false, "SEO": false, "C": [], "CE": { "RW": [], "TF": [], "Cell": [], "L": [], "T": [] }, Height: 25, Width: 160 }; //Excel使用变量 //userid正在使用Excel的ID ID使用文件的ID CP复制区域的实体 TD是否允许拉选 SEO拉选的编辑框 C拉选实体 CE数据库存储变量 US = parent.US; //右键变量 U.Excel.SY["RM"] = { "EO": [["U_E_OptionsImg", "插入", U.Excel.NewTZB], ["U_E_OptionsImg", "删除", U.Excel.DelectSheet]], "LO": [["U_E_OptionsImg", "在上面插入", U.M.apply(this, [[U.Excel.InsertRowsCols, ["T"]]])], ["U_E_OptionsImg", "在下面插入", U.M.apply(this, [[U.Excel.InsertRowsCols, ["B"]]])], ["U_E_OptionsImg", "删除行", U.M.apply(this, [[U.Excel.DeleteRowsCols, ['L']]])], ["U_E_OptionsImg", "锁定行", ""]], "TO": [["U_E_OptionsImg", "在左边插入", U.M.apply(this, [[U.Excel.InsertRowsCols, ["L"]]])], ["U_E_OptionsImg", "在右边插入", U.M.apply(this, [[U.Excel.InsertRowsCols, ["R"]]])], ["U_E_OptionsImg", "删除列", U.M.apply(this, [[U.Excel.DeleteRowsCols, ['T']]])], ["U_E_OptionsImg", "隐藏列", ""], ["U_E_OptionsImg", "锁定列", ""], ["U_E_OptionsImg", "排序", ""], ["U_E_OptionsImg", "筛选", ""], ["U_E_OptionsImg", "列属性", ""]], "SO": [["U_E_OptionsImg", "合并单元格", U.Excel.MergeCells], ["U_E_OptionsImg", "拆分单元格", U.Excel.SplitCell]], "CO": [["U_E_OptionsImg", "批注", ""]], "MO": [["U_E_ICO U_E_TUOJ", "剪切", U.Excel.Cut], ["U_E_ICO ico_07", "复制", U.Excel.CopyFunction], ["U_E_ICO U_E_TUOZ", "粘贴", U.Excel.Paste], ["U_E_OptionsImg", "清除内容", U.M.apply(this, [[U.Excel.EmptyContent, ['InnerHTML']]])]] }; //-----------------------------------------------------------------------------------查看文件的Excel //#region Excel查看 //连接查看Word资料 window.onload = function () { U.D.TopForm(); U.M.ShieldedRightAndSelect(); var _UDID = U.M.QueryString("ID"); if (_UDID) { parent.U.A.Request(US.Auth, ["GetFileContent", _UDID], U.Excel.AsynGOF, [[$("body")[0], true], _UDID]); }; } //获取文件异步 U.Excel.AsynGOF = function (r) { var _UST, _UDID = r.context[1]; r = r.value; U.Excel.SY["ID"] = _UDID; r = U.Excel.CSOPBE(r, _UDID); U.Excel.BLSC(_UDID, r); parent.$("body").addAttrArray({ "innerHTML": U.Excel.CKLBCJ(), "style": { "position": "absolute", "overflow": "auto"} }); } //创建查看列表的 U.Excel.CKLBCJ = function (UWI) { var _UH, _UW, _UDSD, _UDTD, _UDMD, _UGE = U.Excel.SY["CE"]["TF"], _UDPD = $$("div", { "style": { "cssText": "width:100%;height:100%;overflow:auto;"} }); _UDTD = $$("div", { "className": "U_E_CC U_E_CCO", "style": { "position": "static"} }, _UDPD); _UDSD = $$("div", { "className": "U_E_CCL" }, _UDTD); $$("div", { "className": "U_E_CCLT" }, _UDSD); _UDSD = $$("div", { "className": "U_E_CCLC U_E_CCLCO", "style": { "height": "100%"} }, _UDSD); _UDSD = $$("div", { "className": "U_E_LB", "id": "U_E_LB" }, _UDSD); _UH = U.Excel.SPTP(_UGE[0], _UDSD, "L"); _UDSD = $$("div", { "className": "U_E_CCH" }, _UDTD); _UDMD = $$("div", { "className": "U_E_CCB" }, _UDSD); _UDMD = $$("div", { "className": "U_E_TB", "id": "U_E_TB" }, _UDMD); _UW = U.Excel.SPTP(_UGE[1], _UDMD, "T"); _UDSD.style.width = _UW + "px"; _UDTD.style.width = _UW + 51 + "px" _UDMD = $$("div", { "className": "U_E_CCC", "style": { "height": _UH + "px"} }, _UDSD); _UDMD = $$("div", { "className": "U_E_CCCH U_E_CCCHO" }, _UDMD); _UDMD = $$("div", { "className": "U_E_TableArea", "id": "U_E_TableArea" }, _UDMD); U.Excel.CBG(_UGE, _UDMD); _UDSD = $$("div", { "className": "U_E_CX" }, _UDPD); _UDMD = $$("div", { "className": "UD_SYQEXR", "id": "UD_SYQEXR" }, _UDSD); U.Excel.RWD(_UDMD, U.Excel.QHRWL); return _UDPD.outerHTML; } //底部任务栏切换 U.Excel.QHRWL = function (ITF, UW) { UW = UW || window; var _UW, _UH, _UDOD = UW.$("#U_E_TB"), _UDTD = UW.$("#U_E_TableArea"), _UDSD = UW.$("#U_E_LB"), _UKE = UD_SYQEXR, _UDE = U.Excel.SwitchSheetTabs(ITF, true); U.Excel.SY["UW"] = UW; if (_UDE) { document.body.scrollTop = 0; _UH = U.Excel.SPTP(_UDE["TF"][0], _UDSD[0], "L"); _UW = U.Excel.SPTP(_UDE["TF"][1], _UDOD[0], "T"); _UDOD.Parent(2).style.width = _UW + "px"; _UDOD.Parent(3).style.width = _UW + 41 + "px"; U.Excel.CBG(_UDE["TF"], _UDTD[0]); $(_UDTD).Parent(2).style.height = _UH + "px"; U.M.SCT(0, UW.$("body")); U.MR.DHQH(this, "UD_SYQEXROO"); } } //#endregion //-------------------------------------------------------------------------------Excel初始化-------------------------------------------------------------------------- //#region Excel 初始化 //打开保存数据的Excel U.Excel.OPBE = function (UDID, UDE, userid, UAE) { var UDE, _UGE = U.Excel.SY, _UOID = _UGE["ID"]; (UAE && UAE["UFN"]) && (U.Ut.AddObj(U.Excel, UAE["UFN"]), delete UAE["UFN"]); U.Ut.AddObj(_UGE, { "BC": false, "UAE": UAE, "ID": UDID || "ID", "userid": userid, "ET": UDE }); if (UDID) { UDE = UDE || (UDID ? _$(US.Disk.UserDisk[0]).Select({ "UserDirectoryID": UDID }, null, 1) : ""); //获取使用的Excel if (UDE && UDE.UsOffice != null) { UDE.UsOffice = U.Excel.CSOPBE(UDE.UsOffice); U.Excel.BLSC(UDID, UDE.UsOffice); } //设置变量 else { parent.U.A.Request(US.Auth, ["GetFileContent", UDID], U.Excel.AsynOPBE, ["", UDID, UDE, userid, UAE]); return; } } else { UDE = U.Excel.TF["ID"]; U.Excel.BLSC("ID", UDE); } //生成空白的Excel U.Excel.Onload(UDE); //设置初始化Excel } //Office异步 U.Excel.AsynOPBE = function (r) { var context = r.context, _UDID = context[1], _UDE = context[2], _userid = context[3], _UAE = context[4]; r = r.value; r = U.Excel.CSOPBE(r, _UDE.UserDirectoryID); _UDE.UsOffice = r; U.Excel.OPBE(_UDID, _UDE, _userid, _UAE); //打印Excel } //office文件 U.Excel.CSOPBE = function (UDE, UDID) { if ((!UDE || !UDE["Cell"]) || U.Ut.isString(UDE)) { try { eval("0,r=" + UDE); } catch (e) { parent.U.Alert("新初始化文件"); UDE = { "RW": [[]], "TF": [[40, 20]], "Cell": [[]], "L": [[]], "T": [[]] }; (UDID && parent.U.Adisk) && (parent.U.A.Request(US.Auth, ["SaveFileContent", UDID, U.MS.jsonToStr(UDE), ""]), U.M.apply(), [""]); } } return UDE; } //生成全局变量 U.Excel.BLSC = function (UDID, UDE) { var i, j, _UTE = U.Excel.TF, _UGE = U.Excel.SY["CE"]; _UTE[UDID] = UDE; for (j = 0; j < UDE["RW"].length; j++) { if (UDE["RW"][j]) { break; } } //查看的位置 for (i in UDE) { if (UDE.hasOwnProperty(i)) { _UGE[i] = (i == "RW" ? UDE[i] : UDE[i][j]); } } //生成查看变量 return _UGE; } //生成所有的Excel工具 U.Excel.Onload = function () { } //#endregion //#region 页面生成 //生成页面 U.Excel.CNO = function () { var _UGE = U.Excel.SY; U.Excel.RWD(_UGE["UAE"]["XR"]); U.Excel.RefreshTable(); //生成Excel表格 U.Excel.EditOnmousedown($("div", $("#U_E_TableArea")[0])[0], 0); _UGE["TD"] = false; //编辑区域设置 //取消点击 } //生成底部任务栏 U.Excel.RWD = function (UDOD, UTF) { var i, _UGE = U.Excel.SY, _UDE = _UGE["CE"]["RW"], _UDFD = $$("frag"); UDOD = UDOD || _UGE["UAE"]["XR"]; (_UDE.length == 1) && (_UDE[0] = true); UDOD.innerText = ""; for (i = 0; i < _UDE.length; i++) { $$("div", { "innerHTML": "表格" + (i + 1), "className": "UD_SYQEXRO" + (_UDE[i] ? " UD_SYQEXROO" : ""), "onclick": [(UTF || U.Excel.SwitchSheetTabs), [i]], "oncontextmenu": UTF ? "" : [[U.M.StopBubble], [U.Excel.CreateContextMenu, ["Sheet"]]] }, _UDFD); } UDOD.appendChild(_UDFD); } //右键底部任务 U.Excel.RWRD = function (UDOD) { var _UDTD, _UGE = U.Excel.SY, _UDE = _UGE["CE"]["RW"], i = _UDE.length, _UDRD = $(_UGE["UAE"]["D"] || "#U_E_RWRD"), _UDFD = $$("frag"); if (_UDRD[0].style.display == "block") { _UDRD[0].style.display = "none"; } //隐藏列表 else {//查看列表 _UDRD[0].innerText = ""; while (i--) { _UDTD = $$("div", { "className": "U_E_CMOT" + ((!(i % 4) && i != _UDE.length - 2) ? " U_E_CMOO" : ""), "onmousedown": U.M.StopBubble, "onclick": [[U.Excel.SwitchSheetTabs, [i]], [U.Excel.YCCD]] }, _UDFD); $$("div", { "innerHTML": "工作表" + (i + 1) }, _UDTD); } _UDRD.addAttrArray({ "style": { "display": "block", "top": (-(_UDE.length * 30) - 5) + "px", "height": (_UDE.length * 30) + "px"} }); _UDRD[0].appendChild(_UDFD); } } //重新打印表格信息 U.Excel.RefreshTable = function () { var i, _UGE = U.Excel.SY, _UME = _UGE["UAE"], _UDE = _UGE["CE"]["TF"], _UAE = [_UME["L"], _UME["H"], _UME["E"]], _UBE = ["U_E_LB", "U_E_TB", "U_E_TableArea"], _USE = [["SPTP", 0, "L"], ["SPTP", 1, "T"], ["CBG"]]; for (i = 0; i < _UAE.length; i++) { _UAE[i].innerText = ""; _UBE[i] = $$("div", { "className": _UBE[i] }, _UAE[i]); } _UBE[2].id = _UBE[2].className; //生成查看的元素 for (i = 0; i < _USE.length; i++) { U.Excel[_USE[i][0]](_UDE[_USE[i][1]] || _UDE, _UBE[i], _USE[i][2]); } //页面 头部 表格 } //生成横竖排 U.Excel.SPTP = function (UTF, UDOD, UTP) { var i, _UDTD, _UWH = 0, _UCE = {}, _UDE = U.Excel.SY["CE"][UTP], _UAE = UTP == "L" ? ["height", U.Excel.SY.Height + "px", "U_E_LBC", "U_E_LBS", "Left"] : ["width", U.Excel.SY.Width + "px", "U_E_TBC", "U_E_TBS", "Top"], _UDFD = $$("frag"); for (i = 0; i < UTF; i++) { (!_UDE[i]) && (_UCE[_UAE[0]] = _UAE[1], _UDE[i] = { "style": _UCE }); _UWH += parseInt(_UDE[i].style[_UAE[0]]) + 1; _UDTD = $$("div", {}, _UDFD); $$("div", { "style": _UDE[i]["style"], "innerHTML": i + 1, "className": _UAE[2], "onclick": [[U.Excel.RowsColsOnclick, ["this", UTP, i]]], "oncontextmenu": [[U.M.StopBubble], [U.Excel.RowsColsOnclick, ["this", UTP, i]], [U.Excel.CreateContextMenu, [_UAE[4], i]]] }, _UDTD); $$("div", { "className": _UAE[3], "onmousedown": [[U.Excel.Draw, ["this", i, UTP]]] }, _UDTD); } try { UDOD.innerText = ""; UDOD.appendChild(_UDFD); U.Excel.GSPTP(UDOD, UTP, _UWH); } catch (e) { _UDTD = $$("div"); _UDTD.appendChild(_UDFD); UDOD.innerHTML = _UDTD.innerHTML; } return _UWH; } //生成表格 U.Excel.CBG = function (UTF, UDOD) { var i, _UAE, _UWH = [U.Excel.SY.Height, U.Excel.SY.Width], _UGE = U.Excel.SY, _UDSD = $("#UD_SYQEFE")[0], _UDE = _UGE["CE"]["Cell"], _UL = _UDE.length ? _UDE.length : (UTF[0] * UTF[1]), _UDFD = $$("frag"); for (i = 0; i < _UL; i++) { _UAE = _UDE[i] = _UDE[i] || { "style": { "top": (Math.floor(i / UTF[1])) * (_UWH[0] + 1) + "px", "left": (Math.floor(i % UTF[1])) * (_UWH[1] + 1) + "px", "height": _UWH[0] + "px", "width": _UWH[1] + "px"} }; $$("div", { "innerHTML": (_UAE["innerHTML"] || "").replaceHtmlSign(), "ondblclick": [[U.Excel.EditFrameDoubleClick, [_UDSD]]], "style": _UAE["style"], "onmousedown": [[U.Excel.EditOnmousedown, ["this", i]]], "onmouseover": [[U.M.StopBubble], [U.Excel.CellOnmouseover, ["this", i]]], "oncontextmenu": [[U.M.StopBubble], [U.Excel.CreateContextMenu, ["Cell"]]] }, _UDFD); } try { UDOD.innerText = ""; UDOD.appendChild(_UDFD); } catch (e) { _UAE = $$("div"); _UAE.appendChild(_UDFD); UDOD.innerHTML = _UTS.innerHTML; } } //设置横竖排的滚动范围 U.Excel.GSPTP = function (UDOD, UTF, UWH) { var _UTP, _UDTD, _UDSD, _UCE = { "style": {} }, _UGE = U.Excel.SY, _UDE = _UGE["UAE"]; if (_UDE) { _UDTD = _UDE["E"]; _UDSD = _UDE["T"]; _UTP = UTF == "L" ? "height" : "width"; _UDTD.style[_UTP] = UDOD.style[_UTP] = UWH + "px"; _UDSD.style[_UTP] = (UTF == "L" ? UWH + $(_UDSD).Parent().clientHeight - $(UDOD).Parent().clientHeight : UWH + 50) + "px"; } } //设置Excel显示长宽 window.onresize = U.Excel.SetWH = function () { var _UGE = U.Excel.SY["UAE"], _UDOD = $("body")[0], _UW = _UDOD.offsetWidth - 50 - (parent.U.D.SY.ET ? parent.U.D.SY.ET.GDTW : 13), _UH = _UDOD.offsetHeight - 40; if (_UGE && _UW) { $("#U_E_Table")[0].style.height = _UH + "px"; $[_UGE["L"], _UGE["F"]].addAttrArray({ "style": { "height": (_UH - 46) + "px"} }); $("#U_E_CCH")[0].style.width = (_UW) + "px"; } //设置office长宽 } //#endregion //-----------------------------------------------------------------------------底部任务切换------------------------------------------------------------------ //工作表标签切换 U.Excel.SwitchSheetTabs = function (UIF, UTF) { var i, _UGE = U.Excel.SY, _UDE = U.Excel.TF[U.Excel.SY["ID"]], _UKE = _UGE["CE"]; _UGE["UW"] = window; if (_UKE["TF"] !== _UDE["TF"][UIF]) { U.Ut.AddObj(_UKE, { "TF": _UDE["TF"][UIF], "Cell": _UDE["Cell"][UIF], "T": _UDE["T"][UIF], "L": _UDE["L"][UIF] }); //设置当前使用的变量 for (i = 0; i < _UDE["RW"].length; i++) { _UDE["RW"][i] = (i == UIF); }; //切换到指定的工作目录 (!UTF) && (U.Excel.CNO()); return _UKE; //加载刷新表格 } } //新建文件(新建工作表) U.Excel.NWWJ = function () { U.UI.Confirm("是否新建工作表", [U.Excel.NewTZB]); } //新建工作表 U.Excel.NewTZB = function () { var _UGE = U.Excel.SY, _URE = _UGE["CE"]["RW"], _UL = _URE.length, _UDE = U.Excel.TF[U.Excel.SY["ID"]]; _UDE["RW"][_UL] = false; _UDE["TF"][_UL] = [40, 20]; _UDE["T"][_UL] = []; _UDE["L"][_UL] = []; _UDE["Cell"][_UL] = []; //创建新变量 U.Excel.SwitchSheetTabs(_UL); //工作表标签切换 } //--------------------------------------------------------------------------------保存-------------------------------------------------------------------------------- //关闭保存文件 U.Excel.CSave = function (UFUN) { if (U.Excel.SY["BC"] && parent.US.userInfo.userid && U.Excel.SY["userid"] == parent.US.userInfo.userid) { parent.U.UI.Confirm("是否更改保存文件", [U.Excel.Save, [UFUN]], UFUN); } //关闭判断是否保存文件 && parent.U.Dk.M.ufinfoarray("onefind", U.Excel.TF["ID"]).UsOffice else { U.M.apply(this, [UFUN])(); } //关闭 } //保存 U.Excel.Save = function (UFUN) { var _UGE = U.Excel.SY; if (parent.US.userInfo.userid && _UGE["userid"] == parent.US.userInfo.userid) { return parent.U.Dk.LE.USOS(_UGE["ID"], U.MS.jsonToStr(U.Excel.TF[_UGE["ID"]]), "UE", UFUN); } //异步获取Excel else { parent.U.Alert("拒绝访问该文件"); } } //空文件保存异步 U.Excel.YBKWJ = function () { var _UGE = U.Excel.TF, _UDE = arguments, _UCB = _UDE[0]; U.Excel.BLSC(_UDE[1][1].UserDirectoryID, _UGE["ID"]); _UCB(_UDE[1]); _UGE["ID"] = { "RW": [[]], "TF": [[40, 20]], "Cell": [[]], "L": [[]], "T": [[]] }; U.Excel.SY["BC"] = false; } //文件下载成指定的格式 U.Excel.XZZDGS = function () { top.U.D.Office.ZDGSXZ(U.Excel.TF["ID"], "html", U.Excel); } //#region 文件备份 //备份 U.Excel.Backup = function () { } //#endregion //#region //设置权限 U.Excel.CoEd = function () { } //#endregion //---------------------------------------------------------------------------------功能------------------------------------------------------------------------------ //----------------------------------------------------------------------------------------选择功能--------------------------------------------------------------------- //选中效果 U.Excel.RowsColsOnclick = function (UDOD, UTF, ITF) { var i, _UDTD, _UDSD, _UST, _UET, _UME, _UGE = U.Excel.SY, _UDED = $("div", (_UGE["UAE"]["CE"] || $("#U_E_CCCE")[0])), _UTL = _UGE["CE"]["TF"], _UDE = _UGE["CE"]["Cell"], _UDAD = $("div", $("#U_E_TableArea")[0]); (!UDOD) && (UDOD = _UDAD[0]); if (UTF == "D") {//选择区域变化 //选择框大小区域 _UST = _UDE[ITF[1]].style; _UME = [_UST.left, _UST.top, _UST.width, _UST.height]; for (i = 0; i < _UME.length; i++) { _UME[i] = parseInt(_UME[i]); } _UDTD = UDOD[0] || UDOD; _UDSD = UDOD.length ? UDOD : [UDOD]; _UME = [[_UDTD.offsetTop, _UDTD.offsetLeft, 2, (_UME[0] + _UME[2] - _UDTD.offsetLeft)], [_UME[1] + _UME[3], _UDTD.offsetLeft, 2, (_UME[0] + _UME[2] - _UDTD.offsetLeft)], [_UDTD.offsetTop, _UDTD.offsetLeft, (_UME[1] + _UME[3] - _UDTD.offsetTop), 2], [_UDTD.offsetTop, (_UME[0] + _UME[2]), (_UME[1] + _UME[3] - _UDTD.offsetTop), 2]]; //线条范围设置 _UDED.addAttrArray({ "style": { "display": "block", "left": (_UME[3][1] - 6) + "px", "top": (_UME[1][0] - 6) + "px"} }, 2); //点的位置确定 for (i = 0; i < _UME.length; i++) { _UDED.addAttrArray({ "style": { "display": "block", "top": _UME[i][0] + "px", "left": _UME[i][1] + "px", "height": _UME[i][2] + "px", "width": _UME[i][3] + "px"} }, i + 3); } //设置线条 //设置选择的样式 U.Excel.SetHS(); //清除横竖排效果 U.Excel.SubTS(); //清除表格的样式 U.Excel.ChangeEditFrame(_UDTD); //编辑框的效果 U.Excel.ChangeSelectedCell(_UDSD); //改变选中的单元格的样式 U.Excel.ChangeHL(ITF, UTF); //对应的行列变化 } else {//设置选择范围 UTF == "L" ? (_UST = _UTL[1] * ITF, _UET = _UST + _UTL[1] - 1) : UTF == "T" ? (_UST = ITF, _UET = ITF + (_UTL[1] * (_UTL[0] - 1))) : (_UST = 0, _UET = (_UTL[1] * _UTL[0]) - 1); U.Excel.EditOnmousedown(_UDAD[_UST], _UST, true); U.Excel.CellOnmouseover(_UDAD[_UET], _UET); _UGE["TD"] = false; //模拟点击 //模拟移动 return; } } //编辑框的效果 U.Excel.ChangeEditFrame = function (UDOD) { var _UDTD = $(U.Excel.SY["UAE"]["FE"] || "#U_E_EditFrame").addAttrArray({ "style": { "display": "block", "top": UDOD.offsetTop + "px", "left": UDOD.offsetLeft + "px"} }); //编辑框位置 $("div", _UDTD[0]).addAttrArray({ "style": { "backgroundColor": "", "width": (UDOD.offsetWidth - 2) + "px", "height": (UDOD.offsetHeight - 2) + "px"} }); //可编辑大小 } //改变选中的单元格的样式 U.Excel.ChangeSelectedCell = function (UDOD) { var i, UST; if (UDOD && UDOD.length > 0) { if (U.M.HexBack((UST = UDOD[0].style).backgroundColor) == "#a6ffbf") { UST.backgroundColor = ""; } for (i = 1; i < UDOD.length; i++) { (U.M.HexBack((UST = UDOD[i].style).backgroundColor) != "#a6ffbf") && (UST.backgroundColor = "#a6ffbf"); } } } //清除单元格的样式 U.Excel.SubTS = function () { var i, _UST, _UDAD = $("div", $("#U_E_TableArea")[0]), _UDE = U.Excel.SY["CE"]["Cell"], _UDSD = $$("div"); for (i = 0; i < _UDAD.length; i++) { $(_UDSD).addAttrArray(_UDE[i]); _UST = _UDAD[i].style; if (_UST.backgroundColor && _UDSD.style.backgroundColor != _UST.backgroundColor) { _UST.backgroundColor = ""; } } } //对应的行列变化 U.Excel.ChangeHL = function (ITF, UTF) { var i, j, _UDAD, _UDE = [], _UGE = U.Excel.SY, _UIT = _UGE["CE"]["TF"], _UDOD = $($(U.Excel.SY["UAE"]["H"] || "#U_E_TitleBar").Child()[0]).Child(), _UDTD = $($(U.Excel.SY["UAE"]["L"] || "#U_E_LeftLine").Child()[0]).Child(); _UDE = [[ITF[0] % _UIT[1], ITF[1] % _UIT[1], _UDOD], [ITF[0] / _UIT[1], ITF[1] / _UIT[1], _UDTD]] for (i = 0; i < _UDE.length; i++) { for (j = Math.floor(_UDE[i][0]); j <= Math.floor(_UDE[i][1]); j++) { $(_UDE[i][2][j]).Child()[0].style.backgroundColor = "#a6ffbf"; } } //设置选择的颜色 } //清理竖排的样式 U.Excel.SetHS = function () { var i, j, _UTF = "backgroundColor", _UST, _UDOD, _UDAD = [$(U.Excel.SY["UAE"]["H"] || "#U_E_TitleBar"), $(U.Excel.SY["UAE"]["L"] || "#U_E_LeftLine")]; for (i = 0; i < _UDAD.length; i++) { _UDOD = $(_UDAD[i].Child()[0]).Child(); for (j = 0; j < _UDOD.length; j++) { _UST = $(_UDOD[j]).Child()[0].style; (U.M.HexBack(_UST[_UTF]) == "#a6ffbf") && (_UST[_UTF] = ""); } } } //拉伸效果 U.Excel.Draw = function (UDOD, UIF, UTF) { var _UGE = U.Excel.SY, _UDPD = $(UDOD).Parent(2), _UDTD = [_UGE["CE"][UTF][UIF], $("div", UDOD.parentNode)[0]], _UKE = { "style": {} }, _UE = U.M.GetMousep(), _UTE = U.M.GetMousep(), _UDE = U.Excel.GetHSP(UIF, UTF)["Cell"], _UTP = UTF == "L" ? "height" : "width"; UDOD.setCapture(); //聚焦 document.onmousemove = function () { var _UXE = U.M.GetMousep(), _UX = _UXE["X"] - _UE["X"], _UY = _UXE["Y"] - _UE["Y"]; _UE = _UXE; _UDPD.style[_UTP] = parseInt(_UDPD.style[_UTP]) + (UTF == "L" ? _UY : _UX) + "px"; _UKE["style"][_UTP] = Math.max(((parseInt(_UDTD[0].style[_UTP]) || 25) + (UTF == "L" ? _UY : _UX)), 0) + "px"; $(_UDTD).addAttrArray(_UKE); $(_UDE).addAttrArray(_UKE); _UDTD[1].onclick(); //设置变化大小//选中的效果 }; document.onmouseup = function () { var _UDMD = $("#U_E_TableArea")[0], _UXE = U.M.GetMousep(), _UUE = { "left": (_UXE["X"] - _UTE["X"]), "top": (_UXE["Y"] - _UTE["Y"]) }; //变化的值 U.Excel.GXTS(UIF, UTF, _UUE); //更新数据 _UDMD.innerText = ""; U.Excel.CBG("", _UDMD); //从新刷新表格 _UDTD[1].onclick(); //选中的效果 U.Excel.GSPTP(_UDPD, UTF, parseInt(_UDPD.style[_UTP])); //重设滚动条大小 //释放焦点 UDOD.releaseCapture(); document.onmousemove = document.onmouseup = null }; } //获取指定横排 或者是竖排元素 U.Excel.GetHSP = function (ITF, UTF) { var i, _UAE = { "Cell": [], "E": [] }, _UGE = U.Excel.SY["CE"], _UDAD = $("div", $("#U_E_TableArea")[0]), _UDE = _UGE["Cell"], _UTL = _UGE["TF"], _UKE = UTF == "L" ? [_UTL[1] * ITF, _UTL[1] * (ITF + 1), 1] : [ITF, _UTL[1] * _UTL[0], _UTL[1]]; for (i = _UKE[0]; i < _UKE[1]; i += _UKE[2]) { _UAE["Cell"].push(_UDE[i]); _UAE["E"].push(_UDAD[i]); }; return _UAE; //选取横竖排指定的元素 } //获取除拉伸区域外的元素 U.Excel.GetNHSP = function (ITF, UTF) { var i, _UGE = U.Excel.SY["CE"], _UTL = _UGE["TF"], _UCE = _UGE["Cell"], _UDE = { "Cell": [], "E": [] }, _UME = UTF == "L" ? [_UTL[1] * (ITF + 1), -1] : [ITF, ITF]; for (i = _UME[0]; i < _UCE.length; i++) { if (i % _UTL[1] > _UME[1]) { _ UDE["Cell"].push(_UCE[i]); _UDE["E"].push(i); } }; return _UDE; } //更新数据 U.Excel.GXTS = function (ITF, UTF, UDE) { var i, _UAE = U.Excel.GetNHSP(ITF, UTF), _UCE = _UAE["Cell"], _UTP = UTF == "L" ? "top" : "left"; for (i = 0; i < _UCE.length; i++) { _UCE[i].style[_UTP] = (parseInt(_UCE[i].style[_UTP]) + UDE[_UTP]) + "px"; } //更新数据 return _UAE; } //点击小点拖动 U.Excel.DotOnclick = function () { var _UGE = U.Excel.SY, _USE = _UGE["SEO"], _UKE = _UGE["C"][0], _UDOD = (U.Excel.SY["UAE"]["FE"] || $("#U_E_EditFrame")[0]), _UDTD = $("div", _UDOD)[0]; if (_USE[0]) { U.Excel.EditOnmousedown(_USE[0], _USE[1]); //开始选择多个 (_UKE[_UKE.length - 1]) && (_UKE[_UKE.length - 1].onmouseover()); //移动到选择的位置 document.onmouseup = U.M.apply(this, [[U.Excel.SetWZ, [_USE[0].innerHTML]], [U.Excel.ESF]]); //释放 } } //固定区域插入文字 U.Excel.SetWZ = function (UTH) { var i, _UGE = U.Excel.SY, _UDE = _UGE["C"][0], _UAE = _UGE["C"][1], _UCE = _UGE["CE"]["Cell"]; $(_UDE).addAttrArray({ "innerHTML": UTH }); for (i = 0; i < _UAE.length; i++) { _UCE[_UAE[i]].innerHTML = UTH; } //插入值 } //#region 移动选择单元格 //点击移动 U.Excel.EditOnmousedown = function (UDOD, UIE, UTF) { if (UDOD != event) { var i, _UDSD = parent.$("#UD_SYQE input")[2], _URE = U.OU.R, _UDAD = parent.$("#UD_SYQE input"), _UGE = U.Excel.SY, _UDTD = $("div", (_UGE["UAE"]["FE"] || $("#U_E_EditFrame")[0]))[0]; (U.OU.R && !U.OU.TF["FTF"] && U.OU.TF.D) && (U.OU.OUWLJ(_UDSD, "G")); U.OU.TF["FTF"] = true; document.body.focus(); (_UDTD.onblur && _UDTD.onblur()); (UDOD) && (_UGE["SEO"] = [UDOD, UIE]); //赋值 if (event && event.keyCode < 2) {//非键盘事件 (!UDOD) && (UDOD = _UGE["SEO"][0], UIE = _UGE["SEO"][1]); if (event.button != 2 || UTF) {//左键事件触发 _UGE["TD"] = true; UDOD.onmouseover(); //移动选择 (!document.onmouseup) && (document.onmouseup = U.Excel.ESF); //设置取消 return; } } if (U.Excel.ISROC[UDOD], "D", [UIE]) { U.Excel.CellOnmouseover(UDOD, UIE, true); } //判断是否直接切换 } } //释放 U.Excel.ESF = function () { U.Excel.YCCD(); U.Excel.SY["TD"] = false; document.onmouseup = null; } //选择多个单元格 U.Excel.CellOnmouseover = function (UDOD, ITF, UTF) { var _UGE = U.Excel.SY; if (UTF || (_UGE["SEO"] && _UGE["TD"] && !U.M.onmouseout(UDOD))) {//是否进行拉选范围 var i, _UGE = U.Excel.SY, _UL = _UGE["CE"]["TF"][1], _UAE = U.Excel.GetHBTFW(UDOD, ITF), _UDE = [[], []], _UDAD = $("div", $("#U_E_TableArea")[0]); for (i = _UAE[0]; i <= _UAE[1]; i++) { if ((i % _UL >= _UAE[0] % _UL && i % _UL <= _UAE[1] % _UL)) { _UDE[0].push(_UDAD[i]); _UDE[1].push(i); } } //获取选择的 U.Excel.RowsColsOnclick(_UDE[0], "D", _UAE); //选择单元格 if (_UGE["SEO"][1] > _UAE[0]) {//编辑框的范围重新选择 if (_UGE["SEO"][0].offsetWidth > 0) { U.Excel.ChangeEditFrame(_UGE["SEO"][0]); //编辑框的效果 U.Excel.ChangeSelectedCell[_UGE["SEO"][0], _UDE[0][0]]; //改变选中的单元格的样式 } else { _UGE["SEO"] = [_UDAD[_UAE[0]], _UAE[0]]; } } return (_UGE["C"] = _UDE); } } //获取合并表格在的范围 U.Excel.GetHBTFW = function (UDOD, ITF) { if (typeof ITF == "number") { var i, _UST, _UET, _UGE = U.Excel.SY, _UL = _UGE["CE"]["TF"][1], _USL = _UGE["SEO"][1], _UDE = _UGE["CE"]["Cell"], _UKE = []; if (_USL % _UL > ITF % _UL) {//左边计算 if (_USL > ITF) { _UKE[0] = ITF; _UKE[1] = _USL; } //下到上 else { _UKE[0] = (ITF % _UL) + (Math.floor(_USL / _UL) * _UL); _UKE[1] = (_USL % _UL) + (Math.floor(ITF / _UL) * _UL); } //上到下 } else {//右边的计算 if (_USL > ITF) { _UKE[0] = (_USL % _UL) + (Math.floor(ITF / _UL) * _UL); _UKE[1] = (ITF % _UL) + (Math.floor(_USL / _UL) * _UL); } //下到上 else { _UKE[0] = _USL; _UKE[1] = ITF; } //上到下 } for (i = _UKE[0]; i <= _UKE[1]; i++) {//判断是否有合并的单元格 重新计算范围 if ((((_UST = _UDE[i]["Start"]) != null) && (_UET = _UDE[i]["End"])) && (i % _UL >= _UKE[0] % _UL && i % _UL <= _UKE[1] % _UL)) {//范围不在选择的范围 我们重新计算范围 if (_UST % _UL < _UKE[0] % _UL) { if (_UST < _UKE[0]) { i = _UKE[0] = _UST; } else { i = _UKE[0] = (Math.floor(_UKE[0] / _UL) * _UL) + (_UST % _UL); } } else if (_UST < _UKE[0]) { i = _UKE[0] = Math.floor(_UST / _UL) * _UL + (_UKE[0] % _UL); } if (_UET % _UL > _UKE[1] % _UL) { if (_UET > _UKE[1]) { _UKE[1] = _UET; } else { _UKE[1] = (Math.floor(_UKE[1] / _UL) * _UL) + (_UET % _UL); } } else if (_UET > _UKE[1]) { _UKE[1] = (Math.floor(_UET / _UL) * _UL) + (_UKE[1] % _UL); } } } } return _UKE; } //判断是否变成选中效果 U.Excel.ISROC = function (UDOD, UTF, ITF) { var i, _UFT = true, _UDE = U.Excel.SY["C"]; if (event && event.button == 2 && UTF == "D") { for (i = 0; i < _UDE[1].length; i++) { if (_UDE[1][i] == ITF[0]) { _UFT = !_UFT; break; } } if (_UFT) { _UDE = [UDOD, ITF]; } } return _UFT; } //#endregion //-------------------------------------------------------------------------------------编辑区域----------------------------------------------------------------------- document.onkeydown = function () { (event.srcElement.className != "U_E_ASRT") && (U.Excel.Onkeydown()); } //双击变成可编辑 U.Excel.EditFrameDoubleClick = function (UDOD) { var _UDTD = U.Excel.SY["SEO"][0], _UDSD = $("div", UDOD); _UDSD = _UDSD.addAttrArray({ "onblur": [U.Excel.EditFrameOnblur, ["this", _UDTD]], "onselectstart": null, "contentEditable": "true", "className": "U_E_CFEO", "style": { "cssText": "", "height": _UDSD[0].style.height, "width": _UDSD[0].style.width } }, 0)[0]; //设置可编辑 _UDSD.focus(); UDOD.onmousedown = UDOD.ondblclick = null; U.OU.SCJD(_UDSD, _UDTD.innerHTML, ""); U.Excel.SY["BC"] = true; _UDTD.innerText = ""; } //触发编辑应用 U.Excel.Onkeydown = function () { if (U.Excel.SY["UAE"]) { var _UDOD = (U.Excel.SY["UAE"]["FE"] || $("#U_E_EditFrame")[0]), _UDPD = $("div", _UDOD)[0], _UKC = event.keyCode, _UKE = { 9: "R", 13: "B", 108: "B", 38: "T", 40: "B", 37: "L", 39: "R" }; if (_UKE[_UKC]) { U.Excel.Enter(_UKE[_UKC]); } //移动选择 上下左右 tab enter else if (_UDPD.contentEditable != "true" && (_UKC == 229 || ((_UKC > 47 && _UKC < 58) || (_UKC > 64 && _UKC < 91)) || ((_UKC > 95 && _UKC < 112) && (_UKC != 100)))) { //输入直接选择 U.Excel.EditFrameDoubleClick(_UDOD); } } } //单元格换格子事件 U.Excel.Enter = function (UTF, UIT) { var _UDED, _UDAD = $("div", $("#U_E_TableArea")[0]), _UIE = U.Excel.SY["CE"]["TF"]; UIT = UIT || U.Excel.SY["SEO"][1]; //UIT switch (UTF) { case "T": (UIT - _UIE[1] >= 0) && (_UDED = _UDAD[UIT - _UIE[1]]); break; //上 case "L": (UIT - 1 >= Math.floor(UIT / _UIE[1]) * _UIE[1]) && (_UDED = _UDAD[UIT - 1]); break; //左 _UIE[0] * _UIE[1] case "B": (UIT + _UIE[1] < _UIE[0] * _UIE[1]) && (_UDED = _UDAD[UIT + _UIE[1]]); break; //下 case "R": (UIT + 1 < (Math.floor(UIT / _UIE[1]) + 1) * _UIE[1]) && (_UDED = _UDAD[UIT + 1]); break; //右 } if (_UDED) { _UDED.onmousedown(); } } //编辑框失去焦点 U.Excel.EditFrameOnblur = function (UDOD, UDTD) { if (UDOD && UDOD != event && (UDOD.contentEditable == "true" || UDOD.innerText != "") && U.OU.TF["FTF"]) { //失去焦点 var _UDS = UDTD.style, _UDPD = UDOD.parentNode, _UGE = U.Excel.SY, _UDE = _UGE["CE"]["Cell"][_UGE["SEO"][1]], _USE = UDOD.style.cssText; UDTD = _UGE["SEO"][0] || UDTD; //编辑成功保存设置 $(UDTD).addAttrArray({ "innerHTML": (_UDE.innerHTML = UDOD.innerHTML), "style": { "cssText": _USE, "height": _UDS.height, "width": _UDS.width, "left": _UDS.left, "top": _UDS.top} }); _UDE.style.cssText = UDTD.style.cssText; //可编辑区域设置 $(UDOD).addAttrArray({ "contentEditable": "false", "style": { "cssText": "" }, "className": "", "innerHTML": "", "onblur": null, "onselectstart": U.M.StopBubble }); $(_UDPD).addAttrArray({ "ondblclick": [[U.Excel.EditFrameDoubleClick, [_UDPD, true]]], "onmousedown": U.Excel.EditOnmousedown }); //设置点击事件 } else { } // U.OU.TF["FTF"] = true; U.OU.JDCR(); } //--------------------------------------------------------------------------------右键菜单功能----------------------------------------------------------------------- //右键菜单出现和赋值 U.Excel.CreateContextMenu = function (UTF, ITF) { U.M.StopDefault(); var i, _UH, _UDTD, _UDSD = $("#UD_SYQET").Parent(), _UE = U.M.GetMousep(), _UDOD = $(U.Excel.SY["UAE"]["R"] || "#U_E_ContextMenu"), _UDFD = $$("frag"), _UKE = U.Excel.SY["RM"], _UAE = _UKE["MO"], _UCE = { "Cell": ["SO", "CO"], "CellS": ["SO"], "Left": ["LO"], "Top": ["TO"], "Sheet": "TO"}[UTF]; if (_UCE) {//右键菜单 if (_UCE instanceof Array) { for (i = 0; i < _UCE.length; i++) { _UAE = _UAE.concat(_UKE[_UCE[i]]); } } else { _UAE = _UKE[_UCE]; } } else { _UAE = _UKE["CO"]; } for (i = 0; i < _UAE.length; i++) {//生成右键菜单 _UDTD = $$("div", { "className": "U_E_CMO", "style": (!((i + 1) % 4) && i != _UAE.length - 1) ? { "borderBottom": "1px solid #cbcbcb"} : {}, "onmousedown": U.M.StopBubble, "onclick": [[U.Excel.YCCD], [_UAE[i][2], [ITF]]] }, _UDFD); $$("div", { "innerHTML": _UAE[i][1] }, _UDTD); } _UH = _UAE.length * 31; (UTF == "Sheet") && (_UE = U.M.GetElementAllInfo(event.srcElement), _UE["X"] = _UE["TX"] - 1, _UE["Y"] = _UE["TY"] - _UH); (_UE["X"] + 100 > _UDSD.offsetWidth) && (_UE["X"] -= 100); (_UE["Y"] + _UH > _UDSD.offsetHeight) && (_UE["Y"] -= _UH); //位置重新定制 _UDOD[0].innerText = ""; _UDOD[0].appendChild(_UDFD); _UDOD.addAttrArray({ "style": { "display": "block", "left": _UE["X"] + "px", "top": _UE["Y"] + "px"} }); //弹出右键菜单 } //合并单元格 U.Excel.MergeCells = function () { var i, j, _UGE = U.Excel.SY, _UDE = _UGE["C"], _UCE = _UGE["CE"]["Cell"], _UST = _UDE[1][0], _UET = _UDE[1][_UDE[1].length - 1], _UDOD = _UDE[0][0], _UDTD = _UDE[0][_UDE[0].length - 1], _UPE = [[_UDTD, "left", "width", "top", "height"], [_UDOD, "left", "top"]]; if (_UDE[0].length > 1) { for (i = 0; i < _UPE.length; i++) { for (j = 1; j < _UPE[i].length; j++) { _UPE[i][j] = parseInt(_UPE[i][0].style[_UPE[i][j]]); } } for (i = 0; i < _UDE[0].length; i++) { $(_UCE[_UDE[1][i]]).addAttrArray({ "style": { "display": "none" }, "Start": _UST, "End": _UET }); } //设置值 $(_UDE[0]).addAttrArray({ "style": { "display": "none"} }); //设定隐藏合并的范围 $[_UDOD, _UCE[_UDE[1][0]]].addAttrArray({ "style": { "display": "block", "width": _UPE[0][1] + _UPE[0][2] - _UPE[1][1] + "px", "height": _UPE[0][3] + _UPE[0][4] - _UPE[1][2] + "px"} }); //设置可见值 } U.Excel.EditOnmousedown(_UDE[0][0], _UDE[1][0]); U.Excel.SY["TD"] = false; //合并后的区域设为可编辑区域 } //拆分单元格 U.Excel.SplitCell = function () { var _UGE = U.Excel.SY, _UDE = _UGE["CE"]["Cell"], _USE = _UGE["SEO"], _US = _UDE[_USE[1]]["Start"], _UE = _UDE[_USE[1]]["End"]; if (_US) { var i, _UW, _UH, _UDAD = $("div", $("#U_E_TableArea")[0]), _UTL = _UGE["CE"]["TF"][1], _UCE = _UGE["CE"]["Cell"], _UDOD = $($(U.Excel.SY["UAE"]["H"] || "#U_E_TitleBar").Child()[0]).Child(), _UDTD = $($(U.Excel.SY["UAE"]["L"] || "#U_E_LeftLine").Child()[0]).Child(); for (i = _US; i <= _UE; i++) { //查封合并的 if (i % _UTL >= _US % _UTL && i % _UTL <= _UE % _UTL) { if ($(_UDAD[i]).css("width").toInt() > _UDOD[Math.floor(i % _UTL)].offsetWidth) { $[_UDAD[i], _UCE[i]].css({ "width": _UDOD[Math.floor(i % _UTL)].offsetWidth - 1 + "px", "height": _UDTD[Math.floor(i % _UTL)].offsetHeight - 1 + "px" }); } $(_UCE[i]).addAttrArray({ "style": { "display": (_UDAD[i].style.display = "block") }, "Start": null, "End": null }); } } } } //清空内容 U.Excel.EmptyContent = function () { var i, _UGE = U.Excel.SY, _ULE = _UGE["C"][1], _UDE = _UGE["CE"]["Cell"], _UDAD = $("div", $("#U_E_TableArea")[0]); for (i = 0; i < _ULE.length; i++) { _UDAD[_ULE[i]].innerHTML = _UDE[_ULE[i]].innerHTML = ""; } //清空值 } //复制 U.Excel.CopyFunction = function () { var i, _UGE = U.Excel.SY, _UKE = _UGE["C"], _UL = _UKE[1], _UTL = _UGE["CE"]["TF"], _UCJ = (_UL[_UL.length - 1] - _UL[0]); _UGE["CP"] = { "Cell": [], "E": _UL, "CJ": [_UCJ % _UTL[1], Math.floor(_UCJ / _UTL[1])], "CI": [_UTL[0], _UTL[1]] }; for (i = 0; i < _UL.length; i++) { _UGE["CP"]["Cell"].push(_UKE[0][i].innerHTML); } //复制值 } //剪切 U.Excel.Cut = function () { U.Excel.CopyFunction(); U.Excel.EmptyContent(); } //粘贴 U.Excel.Paste = function () { var i, _UXC, _UOI, _UTF, _UME = [], _UGE = U.Excel.SY, _UTL = _UGE["CE"]["TF"], _UCE = _UGE["CP"], _UKE = _UGE["C"], _UTL = _UGE["CE"]["TF"], _UDAD = $("div", $("#U_E_TableArea")[0]); if (_UCE["E"].length) { _UXC = [((_UKE[1][0] % _UTL[1]) + _UCE["CJ"][0]) - _UTL[1] + 1, (Math.floor(_UKE[1][0] / _UTL[1]) + _UCE["CJ"][1] - _UTL[0]) + 1]; for (i = 0; i < _UXC.length; i++) { //扩充横竖排 if (_UXC[i] > 0) { for (j = 0; j < _UXC[i]; j++) { U.Excel.InsertRowsCols.apply(this, i ? ["B", [_UTL[1] * (_UTL[0] - 1), _UTL[1] * _UTL[0] - 1], _UTL[0] - 1, true] : ["R", [_UTL[1] - 1, _UTL[1] * _UTL[0] - 1], _UTL[1] - 1, true]); } _UTF = true; } } _UOI = (_UKE[1][0] + ((_UTL[1] - _UCE["CI"][1]) * Math.floor(_UKE[1][0] / _UCE["CI"][1]))) - ((Math.floor(_UCE["E"][0] / _UCE["CI"][1]) * _UTL[1]) + (_UCE["E"][0] % _UCE["CI"][1])); for (i = 0; i < _UCE["E"].length; i++) { _UME.push(_UOI + (Math.floor(_UCE["E"][i] / _UCE["CI"][1]) * _UTL[1]) + (_UCE["E"][i] % _UCE["CI"][1])); _UGE["CE"]["Cell"][_UME[_UME.length - 1]].innerHTML = _UCE["Cell"][i]; } //设置粘贴值的位置 if (_UTF) { U.Excel.RefreshTable(); } else { for (i = 0; i < _UME.length; i++) { _UDAD[_UME[i]].innerHTML = _UCE["Cell"][i]; }; } //值变化 U.Excel.EditOnmousedown(_UDAD[_UME[0]], _UME[0]); U.Excel.CellOnmouseover(_UDAD[_UME[_UME.length - 1]], _UME[_UME.length - 1]); U.Excel.SY["TD"] = false; U.Excel.YCCD(); //重新聚焦位置 } } //插入横竖排 U.Excel.InsertRowsCols = function (UTF, UFW, UIT, UFT) { var i, j, k, _UTS = {}, _UJE = [], _UDOD = $($(U.Excel.SY["UAE"]["H"] || "#U_E_TitleBar").Child()[0]).Child(), _UDTD = $($(U.Excel.SY["UAE"]["L"] || "#U_E_LeftLine").Child()[0]).Child(), _UGE = U.Excel.SY, _USE = U.Excel.SY["SEO"], _UTL = _UGE["CE"]["TF"], _UCE = _UGE["CE"]["Cell"]; if ("TB".indexOf(UTF) > -1) {//插入横排 (UFW && !UFW.length) && (UIT = UFW, UFW = null); UIT = UIT || (_USE[1] / _UTL[1]); UFW = UFW || [UIT * _UTL[1], (UIT + 1) * _UTL[1] - 1]; (UTF == "B" && UIT != (_UTL[0] - 1)) && (UFW[0] += _UTL[1], UFW[1] += _UTL[1], UIT++); //向下插入 for (i = UFW[0]; i <= UFW[1]; i++) { _UJE.push({ "innerHTML": _UCE[i].innerHTML, "style": { "width": U.Excel.SY.Width + "px", "height": U.Excel.SY.Height + "px", "top": _UCE[i].style.top, "left": _UCE[i].style.left, "display": _UCE[i].style.display || "" }, "End": _UCE[i]["End"], "Start": _UCE[i]["Start"] }); (_UCE[i]["End"]) && (_UTS[_UCE[i]["Start"]] = _UCE[i]["End"]); } //插入数据 for (i in _UTS) { if (Math.floor(i / _UTL[1]) == UIT) { for (j = i % _UTL[1]; j <= _UTS[i] % _UTL[1]; j++) { $(_UJE[j]).addAttrArray({ "style": { "display": "block" }, "End": null, "Start": null }); } } //显示 else { _UCE[i].style.height = parseInt(_UCE[i].style.height) + 31 + "px"; //起始点大小 for (j = i; j < UIT * _UTL[1]; j++) { if (_UCE[j]["End"] && (j % _UTL[1] >= i % _UTL[1] && j % _UTL[1] <= _UTS[i] % _UTL[1])) { _UJE[j % _UTL[1]]["End"] = (_UCE[j]["End"] += _UTL[1]); } } } //起始点放大到指定的大小 } (UIT == (_UTL[1] - 1)) && (UFW[0] += 1); _UTL[0] += 1; for (i = _UJE.length - 1; i >= 0; i--) { _UCE.splice(UFW[0], 0, _UJE[i]); } //插入 _UJE = U.Excel.GXTS(UIT, "L", { "left": 0, "top": 31 })["Cell"]; //改变变化 for (i = 0; i < _UJE.length; i++) { if (((j = _UJE[i]["Start"]) != null)) { (parseInt(j / _UTL[1]) >= UIT) && (_UJE[i]["Start"] += _UTL[1]); _UJE[i]["End"] += _UTL[1]; } } _UGE["CE"]["L"].splice(UIT, 0, { "style": { "height": U.Excel.SY.Height + "px"} }); //添加竖排选择 } else { (UFW && !UFW.length) && (UIT = UFW, UFW = null); UIT = UIT || (_USE[1] % _UTL[1]); UFW = UFW || [UIT, _UTL[0] * _UTL[1]]; (UTF == "R" && UIT != (_UTL[1] - 1)) && (UFW[0] += 1, UIT++); for (i = UFW[0]; i <= UFW[1]; i += _UTL[1]) { _UJE.push({ "style": { "width": U.Excel.SY.Width + "px", "height": U.Excel.SY.Height + "px", "top": _UCE[i].style.top, "left": _UCE[i].style.left, "display": _UCE[i].style.display || "" }, "End": _UCE[i]["End"], "Start": _UCE[i]["Start"] }); (_UCE[i]["End"]) && (_UTS[_UCE[i]["Start"]] = _UCE[i]["End"]); } for (i in _UTS) { i = parseInt(i); if ((i % _UTL[1] == UIT && UTF == "L") || (_UTS[i] % _UTL[1] - 1) == UIT && UTF == "R") { for (j = Math.floor(i / _UTL[1]); j <= (Math.floor(_UTS[i] / _UTL[1]) + 1); j++) { $(_UJE[j]).addAttrArray({ "style": { "display": "block" }, "End": null, "Start": null }); } } // _UJE[j].style.display = "block"; else { _UCE[i].style.width = parseInt(_UCE[i].style.width) + 161 + "px"; } //起始点大小 } (UIT == (_UTL[1] - 1)) && (UFW[0] += 1); _UTL[1]++; for (i = UFW[0]; i < _UTL[1] * _UTL[0]; i += _UTL[1]) { _UCE.splice(i, 0, _UJE[Math.floor(i / _UTL[1])]); } //插入 _UJE = U.Excel.GXTS(UIT, "T", { "left": 161, "top": 0 })["Cell"]; //改变变化 for (i = 0; i < _UCE.length; i++) { if (_UCE[i]["End"]) { if (_UCE[i]["Start"] >= UIT) { _UCE[i]["Start"] += (parseInt(_UCE[i]["Start"] / (_UTL[1] - 1)) + ((_UCE[i]["Start"] % (_UTL[1] - 1) >= UIT) ? 1 : 0)); } if (_UCE[i]["End"] > UIT) { _UCE[i]["End"] += (parseInt(_UCE[i]["End"] / (_UTL[1] - 1)) + ((_UCE[i]["End"] % (_UTL[1] - 1) < UIT) ? 0 : 1)); } } } _UGE["CE"]["T"].splice(UIT, 0, { "style": { "width": "160px"} }); //添加竖排选择 } (!UFT) && (U.Excel.RefreshTable(), (("TB".indexOf(UTF) > -1) ? _UDTD : _UDOD)[UIT].onclick()); //更新 } //删除行 U.Excel.DeleteRowsCols = function (UTF, ITF) { var i, _UST, _UET, _UDE, _UGE = U.Excel.SY, _UCE = _UGE["CE"], _UTL = _UCE["TF"], _UKE = _UCE["Cell"]; if (UTF == "L") {//行删除 _UDE = _UKE.splice(ITF * _UTL[1], _UTL[1]); //删除的表格数据 for (i = 0; i < _UDE.length; i++) { if ((_UET = _UDE[i]["End"])) { if (Math.floor((_UST = _UDE[i]["Start"]) / _UTL[1]) == ITF && Math.floor(_UET / _UTL[1]) > ITF) { $(_UKE[_UST]).addAttrArray({ "style": { "width": _UDE[i].style.width, "height": parseInt(_UDE[i].style.height) - parseInt(_UCE["L"][ITF].style.height) - 1 + "px", "display": "block" }, "innerHTML": _UDE[i].innerHTML || "" }); } //重新设置 else if (Math.floor(_UST / _UTL[1]) != ITF && Math.floor(_UET / _UTL[1]) >= ITF) { $(_UKE[_UST]).addAttrArray({ "style": { "height": parseInt(_UKE[_UST].style.height) - (parseInt(_UCE["L"][ITF].style.height) || U.Excel.SY.Height) - 1 + "px"} }); } //设置 i = _UET % _UTL[1]; } } U.Excel.GXTS(ITF - 1, UTF, { "top": -(parseInt(_UCE["L"][ITF].style.height) + 1), "left": 0 }); //删除后的修改 _UCE["L"].splice(ITF, 1); _UTL[0]--; //删除列的信息 for (i = 0; i < _UKE.length; i++) { //解决位置变化后的合并的起始结束的问题 if ((_UET = _UKE[i]["End"])) { if (Math.floor((_UST = _UKE[i]["Start"]) / _UTL[1]) > ITF) { _UKE[i]["Start"] -= _UTL[1]; } _UKE[i]["End"] -= _UTL[1]; } } } else {//列删除 _UDE = []; for (i = 0; i < _UTL[0]; i++) { _UDE.push(_UKE.splice(ITF + (i * _UTL[1]) - i, 1)[0]); } //删除表格的值 for (i = 0; i < _UDE.length; i++) { if ((_UET = _UDE[i]["End"])) { if ((_UST = _UDE[i]["Start"]) % _UTL[1] == ITF && _UET % _UTL[1] > ITF) { $(_UKE[_UST - Math.floor(_UST / _UTL[1])]).addAttrArray({ "style": { "width": parseInt(_UDE[i].style.width) - parseInt(_UCE["T"][ITF].style.width) - 1 + "px", "height": _UDE[i].style.height, "display": "block" }, "innerHTML": _UDE[i].innerHTML || "" }); } else if (_UST % _UTL[1] != ITF && _UET % _UTL[1] >= ITF) { $(_UKE[_UST - Math.floor(_UST / _UTL[1])]).addAttrArray({ "style": { "width": parseInt(_UKE[_UST - Math.floor(_UST / _UTL[1])].style.width) - (parseInt(_UCE["L"][ITF].style.width) || 160) - 1 + "px"} }); } i = Math.floor(_UET / _UTL[1]); } } _UCE["T"].splice(ITF, 1); _UTL[1]--; //删除列的信息 U.Excel.GXTS(ITF - 1, UTF, { "top": 0, "left": -(parseInt(_UCE["T"][ITF].style.width) + 1) }); //删除后的修改 for (i = 0; i < _UKE.length; i++) { //解决位置变化后的合并的起始结束的问题 if ((_UET = _UKE[i]["End"])) { _UKE[i]["Start"] -= parseInt(_UKE[i]["Start"] / (_UTL[1] + 1)); _UKE[i]["End"] -= (parseInt(_UET / (_UTL[1] + 1)) + 1); } } } U.Excel.RefreshTable(); //从新刷新表格 } //删除工作页 U.Excel.DelectSheet = function () { var i, j, _UGE = U.Excel.TF[U.Excel.SY["ID"]], _UDE = U.Excel.SY["CE"]; if (_UGE.length != 1) {//工作页要大于一 for (i = 0; i < _UGE.length; i++) { if (_UGE[i]["Cell"] == _UDE["Cell"]) { for (j in _UDE) { _UGE[i][j].splice(i, 1); } } //移除工作表变量 } U.Excel.SwitchSheetTabs(i - 1 < 0 ? 0 : i - 1); //切换到指定 } } //隐藏菜单 U.Excel.YCCD = function () { var i, _UGE = U.Excel.SY["UAE"], _UDE = [["D", "U_E_RWRD"], ["R", "U_E_ContextMenu"]]; U.OU.SDYC(null, true); //隐藏默认的菜单 for (i = 0; i < _UDE.length; i++) { (_UGE[_UDE[i][0]] || $("#" + _UDE[i][1])).style.display = "none"; } //隐藏Excel菜单 } //---------------------------------------------------------------------------------滚动条功能------------------------------------------------------------------------- //滚动条 U.Excel.BS = function (UDOD) { var _UGE = U.Excel.SY["UAE"], _UT = UDOD.scrollTop, _UL = UDOD.scrollLeft, _UDTD = _UGE["F"] || $("#U_E_CellF")[0], _UDSD = _UGE["L"] || $("#U_E_LeftLine")[0], _UDMD = _UGE["H"] || $("#U_E_TitleBar")[0]; if (_UT - _UDTD.scrollTop) { _UDTD.scrollTop = _UT; _UDSD.scrollTop = _UDTD.scrollTop; } //滚动表和左边的变化 if (_UL - _UDTD.scrollLeft) { _UDTD.scrollLeft = _UL; _UDMD.scrollLeft = _UDTD.scrollLeft; } //滚动表头部的变化 } //滚动条变化 U.Excel.GBH = function () { var _UW = event.wheelDelta, _UWD = _UW ? (_UW / 120) : (-event.detail / 3); $(U.Excel.SY["UAE"]["T"] || "#U_E_CB").Parent().scrollTop -= _UWD * 50; } window.onerror = function () { return true; } document.oncontextmenu = U.M.StopDefault;