String concatenation operators.(Microsoft Excel Office Scripts)
This section introduces the use of string concatenation operators in Office scripts.
Contents
Operations
In VBA macros, I used "+" or "&" to join strings,Office scripts use only "+".
function main(workbook: ExcelScript.Workbook) {
let s1: string = "ABC";
let s2: string = "ABC";
let s3: string = "";
s3 = s1 + s2;
workbook.getWorksheet("Test").getRange("A2").setValue(s1);
}
To combine numbers as strings, use the toString() method to convert numbers to strings.
numeric.toString()
function main(workbook: ExcelScript.Workbook) {
let n1: Number = 123;
let n2: Number = 456;
let s: string = "";
s = n1.toString() + n2.toString();
workbook.getWorksheet("Test").getRange("A2").setValue(s);
}
The "+=" is used to join a string of type string on the left-hand side followed by a string on the right-hand side.
For those who want to learn Office script effectively
The information on this site is now available in an easy-to-read e-book format.
Or Kindle Unlimited (unlimited reading).
You willl discover how to about basic operations.
By the end of this book, you will be equipped with the knowledge you need to use Excel Office Script to streamline your workflow.
Discussion
New Comments
No comments yet. Be the first one!