我在 Excel 中有一列数字:
column A
row ----------
1 2.11
2 1.123
3 2.222
4 ...
5 ...
6 ...
我想要做的是按行号(而不是按单元格中的值)以相反的顺序对它们进行排序,这意味着我将得到以下结果:
column A
row ----------
1 ...
2 ...
3 ...
4 2.222
5 1.123
6 2.11
有没有办法做到这一点?
答案1
我最终编写了 javascript 来完成这项工作,代码如下:
var total_coordinates = 0;
var coordinates_array = [];
var doneReading = false;
function loadCoordinatesFile() {
var oFrame = document.getElementById('coordinatesFrame');
var oFrameReOrdered = document.getElementById('coordinatesFrameReorderd');
var strRawContents = oFrame.contentWindow.document.body.childNodes[0].innerHTML;
while (strRawContents.indexOf("\r") >= 0)
strRawContents = strRawContents.replace("\r", "");
var arrLines = strRawContents.split("\n");
for (var i = arrLines.length-1; i >= 0; i--) {
console.log("line = " + arrLines[i]);
var curLine = arrLines[i];
total_coordinates = total_coordinates + 1;
coordinates_array.push(curLine);
oFrameReOrdered.contentWindow.document.write(curLine + "<br>");
}
}