Is there a way to copy a column or a range of cells from one worksheet to another? There are ways to copy ranges of cells within the worksheet, but I am looking to copy cells from one worksheet to another.
I am working with the excel javascript api to create an excel addin.
I found a solution. This works by passing a range to the copyFrom method.
async function run() {
await Excel.run(function (context) {
var currentWorksheet = context.workbook.worksheets.getActiveWorksheet();
currentWorksheet.load("name");
var otherSheet = context.workbook.worksheets.add("other-sheet");
otherSheet.load("name, position");
var tbACol = currentWorksheet.getRange("A1:A200");
otherSheet.getRange("A1:A3").copyFrom(tbACol);
return context.sync().then(function () {
console.log(`Added worksheet named "${otherSheet.name}" in position ${otherSheet.position}`);
});
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.