var tableName = 表1;
var startDimLoc = 3;
var startMeaLoc = -51;//
var totSelnum = 12;//动态列总数
var colList=[区域名称维,城市公司维,项目编码维,项目名称维,分期编码维,分期名称维,一级业态维,二级业态维,装修标准维,产品编码维,产品名称维,持股比例维];
var spanColDim = getColStatus(colList);
var selColCnt = spanColDim.length; //勾选的动态列数
var totColNum = tableName.binding.colCount; //绑定字段总列数
var curColNum = totColNum - totSelnum + selColCnt; //获取当前总列数
//向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);
}
//
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);