你们的这个方法我使用的时候,只能实现其中一个功能,就是居中,但是只是放在宽的中间, 没有在高和宽的最中间
function setAlignment(sheet, type, value){
var sels = sheet.getSelections();
var rowCount = sheet.getRowCount();
var columnCount = sheet.getColumnCount();
var align;
value = value.toLowerCase();
if (value === "middle") {
alert(value);
value = "center";
}
if (type === "hAlign") {
align = spreadNS.HorizontalAlign[value];
} else {
align = spreadNS.VerticalAlign[value];
}
sheet.suspendPaint();
for (var n = 0; n < sels.length; n++) {
var sel = getActualCellRange(sheet, sels[n], rowCount, columnCount);
sheet.getRange(sel.row, sel.col, sel.rowCount, sel.colCount)[type](align);
}
sheet.resumePaint();
}
我是这样写的:switch(num){
case "1":
setAlignment(activeSheet,"hAlign","top");
break;
case "2":
setAlignment(activeSheet,"hAlign","middle");
break;
case "3":
setAlignment(activeSheet,"hAlign","bottom");
break;
case "4":
setAlignment(activeSheet,"hAlign","middle");
break;
case "5":
setAlignment(activeSheet,"vAlign","left");
break;
case "6":
setAlignment(activeSheet,"vAlign","middle");
break;
case "7":
setAlignment(activeSheet,"vAlign","right");
break;
default:
setAlignment(activeSheet,"vAlign","middle");
break;} |