Here's what I'm trying to accomplish using the Excel Javascript API:
- I have a
Sheet1
andSheet2
in my workbook. WithinSheet2
there may be some references to cells inSheet2
, but I don't know where or even if they exist. - I'd like to replace
Sheet1
with a different sheet (saySheet3
), but I don't want to the references to cells toSheet1
onSheet2
to break. - Both
Sheet1
andSheet2
have arbitrary amount of data on them, and have an unbounded amount as well.
My question: how can I perform the above operation, using only the Excel Javascript API, in an efficient way?
Here are a few solutions I've thought about (some I've tried):
- Delete
Sheet1
. RenameSheet3
toSheet1
. This does not work, as it causes the references toSheet1
inSheet2
to become undefined. - Find and replace all instances of
Sheet1
withSheet3
inSheet2
before the delete and rename. I am concerned this will not be efficient enough as it must look through all cells. - Pause calculation, then delete, then rename, then resume calculation. This does not work as pausing calculation apparently doesn't pause this kind of reference updating, and so the references in
Sheet2
toSheet1
still break. - Copy all cell data from
Sheet3
toSheet1
. However, as we would also need to copy formatting, which as far as I understand cannot be done in bulk. I don't think we could do this efficiently enough, as there may be an arbitrary amount of data.
Any feedback would be greatly appreciated. Without a solution, I fear it may tank a month or so of work on our add-in :(