How to use the Office.JS API to link to a cell in another workbook using SheetJS

148 Views Asked by At

How to insert a link to a cell from another workbook in a cell? What should be the format? I tried: #'[WorkbookName]sheetName'!D4

1

There are 1 best solutions below

0
On

We could try to do that like below sample code, set the cell’s value with the formula which links to another workbook.

async function run() {
await Excel.run(async (context) => {
const range = context.workbook.getSelectedRange().getCell(0, 0); //replace the ‘teststyle.xlsx’ with the workbook name you will reference
range.values = [["=[teststyle.xlsx]Sheet1!$A$1"]];  

await context.sync();

console.log("Set formula successfully!");

}); }