Created
April 20, 2020 05:32
-
-
Save rheajt/801e17b9adfff8b0a6a9b805e37b5999 to your computer and use it in GitHub Desktop.
[UpdateNamedRangs] excel typescript to update the ranges of all named ranges in a workbook #excel #typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function main(context: Excel.RequestContext) { | |
// Your code here | |
const items = context.workbook.names.load('items') | |
await context.sync(); | |
items.items.forEach(item => { | |
const lastIndex = item.formula.lastIndexOf('$'); | |
const main = item.formula.substring(0, lastIndex + 1); | |
const split = +item.formula.substring(lastIndex + 1); | |
console.log(main, split +5); | |
item.set({formula: `${main}${split + 5}`}); | |
}); | |
await context.sync(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment