那你参考这个写一下
function testRemove(str) {
if (str != null) return str.toUpperCase() == "REMOVE";
else return true;
}
var selStartIndex = integer(p_dim_region.getSelectedObjects().length + p_dim_bu_name.getSelectedObjects().length + p_dim_pd_name.getSelectedObjects().length + (testRemove(下拉列表参数4.getSelectedObjects()[0]) ? 0 : 1) + (testRemove(下拉列表参数5.getSelectedObjects()[0]) ? 0 : 1))
//向loc对应的格子输入文字message
function setLocatorMessage(elemName, loc, message) {
var elem_v = eval(elemName);
elem_v.setFormat(loc, MESSAGE_FORMAT);
elem_v.setFormatPattern(loc, message);
}
//设置合并单元格,locStart对应的格子,向右x个格子,向下y个格子,边框的类型,文字和背景色、前景色
function setcellSpan(elemName, locStart, x, y, lineColor, lineType, bc, fc, message) {
var elem_v = eval(elemName);
elem_v.setSpan(locStart, new Dimension(x, y));
var c1 = new Insets(lineType, lineType, lineType, lineType);
elem_v.setBorders(locStart, c1);
elem_v.setBorderColor(locStart, lineColor);
elem_v.setForeground(locStart, fc);
elem_v.setBackground(locStart, bc);
setLocatorMessage(elemName, locStart, message)
}
//清除区域内所有的边框
function clearAllBorder(elemName, loc_start_r, loc_start_c, x, y) {
var elem_v = eval(elemName);
var loc_end_c = integer(loc_start_c + x - 1);
var loc_end_r = integer(loc_start_r + y - 1);
//遍历每一个格子
for (var i = loc_start_c; i <= loc_end_c; i++) {
for (var j = loc_start_r; j <= loc_end_r; j++) {
var index_up_i = j + "," + i;
var loc_up_i = new Locator([index_up_i], CELL, HEADER);
var c = new Insets(NO_BORDER, NO_BORDER, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_up_i, c);
setLocatorMessage(elemName, loc_up_i, "");
}
}
}
//
function setelemHeaderspan(elemName, loc_start_r, loc_start_c, x, y, isSpan, lineColor, lineType, bc, fc, message) {
var elem_v = eval(elemName);
var loc_end_c = integer(loc_start_c + x - 1);
var loc_end_r = integer(loc_start_r + y - 1);
var loc_start = new Locator([loc_start_r + "," + loc_start_c], CELL, HEADER);
clearAllBorder(elemName, loc_start_r, loc_start_c, x, y);
if (isSpan) { //如果需要合并单元格
setcellSpan(elemName, loc_start, x, y, lineColor, lineType, bc, fc, message)
} else {
if (x == 1 && y == 1) {
//直接画边框
var c = new Insets(lineType, lineType, lineType, lineType);
elem_v.setBorders(loc_start, c);
elem_v.setBorderColor(loc_start, lineColor);
} else {
//设置上边框
for (var i = loc_start_c; i <= loc_end_c; i++) {
var index_up_i = loc_start_r + "," + i;
var loc_up_i = new Locator([index_up_i], CELL, HEADER);
var c = new Insets(lineType, NO_BORDER, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_up_i, c);
elem_v.setBorderColor(loc_up_i, lineColor);
}
//设置左边框
var loc_left_0 = new Locator([loc_start_r + "," + loc_start_c], CELL, HEADER);
var c = new Insets(lineType, lineType, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_left_0, c);
elem_v.setBorderColor(loc_left_0, lineColor);
for (var i = loc_start_r + 1; i <= loc_end_r; i++) {
var index_left_i = i + "," + loc_start_c;
var loc_left_i = new Locator([index_left_i], CELL, HEADER);
var c = new Insets(NO_BORDER, lineType, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_left_i, c);
elem_v.setBorderColor(loc_left_i, lineColor);
}
//设置下边框
var loc_bottom_0 = new Locator([loc_end_r + "," + loc_start_c], CELL, HEADER);
var c = new Insets(NO_BORDER, lineType, lineType, NO_BORDER);
elem_v.setBorders(loc_bottom_0, c);
elem_v.setBorderColor(loc_bottom_0, lineColor);
for (var i = loc_start_c + 1; i <= loc_end_c; i++) {
var index_bottom_i = loc_end_r + "," + i;
var loc_bottom_i = new Locator([index_bottom_i], CELL, HEADER);
var c = new Insets(NO_BORDER, NO_BORDER, lineType, NO_BORDER);
elem_v.setBorders(loc_bottom_i, c);
elem_v.setBorderColor(loc_bottom_i, lineColor);
}
//设置右边框
var loc_right_0 = new Locator([loc_end_r + "," + loc_end_c], CELL, HEADER);
var c = new Insets(NO_BORDER, NO_BORDER, lineType, lineType);
elem_v.setBorders(loc_right_0, c);
elem_v.setBorderColor(loc_right_0, lineColor);
for (var i = loc_start_r + 1; i < loc_end_r; i++) {
var index_right_i = i + "," + loc_end_c;
var loc_right_i = new Locator([index_right_i], CELL, HEADER);
var c = new Insets(NO_BORDER, NO_BORDER, NO_BORDER, lineType);
elem_v.setBorders(loc_right_i, c);
elem_v.setBorderColor(loc_right_i, lineColor);
}
var loc_right_e = new Locator([loc_start_r + "," + loc_end_c], CELL, HEADER);
var c = new Insets(lineType, NO_BORDER, NO_BORDER, lineType);
elem_v.setBorders(loc_right_e, c);
elem_v.setBorderColor(loc_right_e, lineColor);
if (y == 1) {
var c = new Insets(lineType, lineType, lineType, NO_BORDER);
elem_v.setBorders(loc_start, c);
elem_v.setBorderColor(loc_start, lineColor);
for (var i = loc_start_c + 1; i < loc_end_c; i++) {
var index_right_i = loc_start_r + "," + i;
var loc_right_i = new Locator([index_right_i], CELL, HEADER);
var c = new Insets(lineType, NO_BORDER, lineType, NO_BORDER);
elem_v.setBorders(loc_right_i, c);
elem_v.setBorderColor(loc_right_i, lineColor);
}
var loc_right_e = new Locator([loc_start_r + "," + loc_end_c], CELL, HEADER);
var c = new Insets(lineType, NO_BORDER, lineType, lineType);
elem_v.setBorders(loc_right_e, c);
elem_v.setBorderColor(loc_right_e, lineColor);
}
if (x == 1) {
var c = new Insets(lineType, lineType, NO_BORDER, lineType);
elem_v.setBorders(loc_start, c);
elem_v.setBorderColor(loc_start, lineColor);
for (var i = loc_start_r + 1; i < loc_end_r; i++) {
var index_right_i = i + "," + loc_start_c;
var loc_right_i = new Locator([index_right_i], CELL, HEADER);
var c = new Insets(NO_BORDER, lineType, NO_BORDER, lineType);
elem_v.setBorders(loc_right_i, c);
elem_v.setBorderColor(loc_right_i, lineColor);
}
var loc_right_e = new Locator([loc_end_r + "," + loc_end_c], CELL, HEADER);
var c = new Insets(NO_BORDER, lineType, lineType, lineType);
elem_v.setBorders(loc_right_e, c);
elem_v.setBorderColor(loc_right_e, lineColor);
}
elem_v.setForeground(loc_start, fc);
elem_v.setBackground(loc_start, bc);
}
//向起始格子设置文字
setLocatorMessage(elemName, loc_start, message)
}
}
//
function setelemCellspan(elemName, loc_start_r, loc_start_c, x, y, isSpan, lineColor, lineType, bc, fc, message) {
var elem_v = eval(elemName);
var loc_end_c = integer(loc_start_c + x - 1);
var loc_end_r = integer(loc_start_r + y - 1);
//debug(loc_start_r+",,,,,,,"+loc_start_c)
//debug(loc_end_r+",,,,,,,"+loc_end_c)
var loc_start = new Locator([loc_start_r + "," + loc_start_c], CELL, DETAIL);
if (isSpan) { //如果需要合并单元格
setcellSpan(elemName, loc_start, x, y, lineColor, lineType, bc, fc, message)
} else {
if (x == 1 && y == 1) {
//直接画边框
var c = new Insets(lineType, lineType, lineType, lineType);
elem_v.setBorders(loc_start, c);
elem_v.setBorderColor(loc_start, lineColor);
} else {
//设置上边框
for (var i = loc_start_c; i <= loc_end_c; i++) {
var index_up_i = loc_start_r + "," + i;
var loc_up_i = new Locator([index_up_i], CELL, DETAIL);
var c = new Insets(lineType, NO_BORDER, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_up_i, c);
elem_v.setBorderColor(loc_up_i, lineColor);
}
//设置左边框
var loc_left_0 = new Locator([loc_start_r + "," + loc_start_c], CELL, DETAIL);
var c = new Insets(lineType, lineType, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_left_0, c);
elem_v.setBorderColor(loc_left_0, lineColor);
for (var i = loc_start_r + 1; i <= loc_end_r; i++) {
var index_left_i = i + "," + loc_start_c;
var loc_left_i = new Locator([index_left_i], CELL, DETAIL);
var c = new Insets(NO_BORDER, lineType, NO_BORDER, NO_BORDER);
elem_v.setBorders(loc_left_i, c);
elem_v.setBorderColor(loc_left_i, lineColor);
}
//设置下边框
var loc_bottom_0 = new Locator([loc_end_r + "," + loc_start_c], CELL, DETAIL);
var c = new Insets(NO_BORDER, lineType, lineType, NO_BORDER);
elem_v.setBorders(loc_bottom_0, c);
elem_v.setBorderColor(loc_bottom_0, lineColor);
for (var i = loc_start_c + 1; i <= loc_end_c; i++) {
var index_bottom_i = loc_end_r + "," + i;
var loc_bottom_i = new Locator([index_bottom_i], CELL, DETAIL);
var c = new Insets(NO_BORDER, NO_BORDER, lineType, NO_BORDER);
elem_v.setBorders(loc_bottom_i, c);
elem_v.setBorderColor(loc_bottom_i, lineColor);
}
//设置右边框
var loc_right_0 = new Locator([loc_end_r + "," + loc_end_c], CELL, DETAIL);
var c = new Insets(NO_BORDER, NO_BORDER, lineType, lineType);
elem_v.setBorders(loc_right_0, c);
elem_v.setBorderColor(loc_right_0, lineColor);
for (var i = loc_start_r + 1; i < loc_end_r; i++) {
var index_right_i = i + "," + loc_end_c;
var loc_right_i = new Locator([index_right_i], CELL, DETAIL);
var c = new Insets(NO_BORDER, NO_BORDER, NO_BORDER, lineType);
elem_v.setBorders(loc_right_i, c);
elem_v.setBorderColor(loc_right_i, lineColor);
}
var loc_right_e = new Locator([loc_start_r + "," + loc_end_c], CELL, DETAIL);
var c = new Insets(lineType, NO_BORDER, NO_BORDER, lineType);
elem_v.setBorders(loc_right_e, c);
elem_v.setBorderColor(loc_right_e, lineColor);
if (y == 1) {
var c = new Insets(lineType, lineType, lineType, NO_BORDER);
elem_v.setBorders(loc_start, c);
elem_v.setBorderColor(loc_start, lineColor);
for (var i = loc_start_c + 1; i < loc_end_c; i++) {
var index_right_i = loc_start_r + "," + i;
var loc_right_i = new Locator([index_right_i], CELL, DETAIL);
var c = new Insets(lineType, NO_BORDER, lineType, NO_BORDER);
elem_v.setBorders(loc_right_i, c);
elem_v.setBorderColor(loc_right_i, lineColor);
}
var loc_right_e = new Locator([loc_start_r + "," + loc_end_c], CELL, DETAIL);
var c = new Insets(lineType, NO_BORDER, lineType, lineType);
elem_v.setBorders(loc_right_e, c);
elem_v.setBorderColor(loc_right_e, lineColor);
}
if (x == 1) {
var c = new Insets(lineType, lineType, NO_BORDER, lineType);
elem_v.setBorders(loc_start, c);
elem_v.setBorderColor(loc_start, lineColor);
for (var i = loc_start_r + 1; i < loc_end_r; i++) {
var index_right_i = i + "," + loc_start_c;
var loc_right_i = new Locator([index_right_i], CELL, DETAIL);
var c = new Insets(NO_BORDER, lineType, NO_BORDER, lineType);
elem_v.setBorders(loc_right_i, c);
elem_v.setBorderColor(loc_right_i, lineColor);
}
var loc_right_e = new Locator([loc_end_r + "," + loc_end_c], CELL, DETAIL);
var c = new Insets(NO_BORDER, lineType, lineType, lineType);
elem_v.setBorders(loc_right_e, c);
elem_v.setBorderColor(loc_right_e, lineColor);
}
elem_v.setForeground(loc_start, fc);
elem_v.setBackground(loc_start, bc);
}
//向起始格子设置文字
setLocatorMessage(elemName, loc_start, message)
}
}
|