function CellChar(CellOrder, InitialCell) {
var dividend = CellOrder + InitialCell;
var res = "";
var modulo;
while (dividend > 0) {
modulo = (dividend - 1) % 26;
res = String.fromCharCode(65 + modulo) + res;
dividend = Math.floor((dividend - modulo) / 26);
}
return res;
}
function getSelectionRange() {
var selectedRanges = spread.getActiveSheet().getSelections();
var range = "";
if (selectedRanges.length > 0) {
if (selectedRanges[0].colCount == 1 && selectedRanges[0].rowCount == 1) {
range = CellChar(selectedRanges[0].col + 1, 0);
range = range + (selectedRanges[0].row + 1)
}
else {
range = CellChar(selectedRanges[0].col + 1, 0);
range = range + (selectedRanges[0].row + 1) + ":"
range = range + CellChar(selectedRanges[0].col + 1 + selectedRanges[0].colCount - 1, 0);
range = range + (selectedRanges[0].row + 1 + selectedRanges[0].rowCount - 1);
}
}
return range;
} |