assign a value to the cell in the first row
1. There is an ASCII code in the computer, in which A
the number represented in the computer is 65, a
the ASCII code is 97, b
and the ASCII code is 98.
2. From A1
to, F1
you can see that the first letter is changing, the second number is always 1, the A
ASCII code is 65, F
and the ASCII code is 70.
3. We define letter=65, so that the letter gradually approaches 70.
4. Sheets.Item(1).Range("A1").Value2='小知识酷'
We have learned that this line of code means that the value of cell A1 is "cool knowledge", so we only need to increment the value at position A.
5. String.fromCharCode(letter)
, letter
is a variable defined by yourself, String.fromCharCode(65)
which converts the ascii code into characters A
.
function test(){
for(var letter = 65;letter <= 70; letter++){
Sheets.Item(1).Range(String.fromCharCode(letter) +"1").Value2 = letter;
}
}
Replenish
1. If you define it directly letter = 'a'
, and then make the letter gradually increase, I tried it, but it doesn't work. It will only output the first value.
function test(){
for(var letter = 'a';letter <= 'c'; letter++){
Sheets.Item(1).Range(letter+"1").Value2 = letter;
}
}
2. To simplify the code, the window will input a
,#QNAN
function test(){
var letter = 'a';
alert(letter);
++letter;
alert(letter);
}
3. Add 1 to the value of letter to make it larger. The window will enter a
, a1
, and they will be linked.
function test(){
var letter = 'a';
alert(letter);
letter = letter + 1;
alert(letter);
}
WPS JS gets the total number of rows of the worksheet
Get the total number of rows in the worksheet being used
function UsedRangeNum(){
let a=ActiveSheet.UsedRange.Rows.Count;
alert(a);
}
- Get the total number of table rows used in the first table:
var colcount=wb.Worksheets(1).UsedRange.Cells.Rows.Count ;
- Get the total number of columns used in the first table:
var colcolumn=wb.Worksheets(1).UsedRange.Columns.Count;
- Get the total number of rows used in the table "Little Knowledge Cool":
var colcount=wb.Worksheets(“小知识酷”).UsedRange.Cells.Rows.Count ;