Office.js code in Excel

Office.js is the programming interface Excel gives add-ins. When none of Oda's other steps can do a task, DataMind Oda in Excel can write a short piece of Office.js code and run it, for example to set a chart option the other steps lack or to make many small edits in one go. Every change the code asks for is checked and approved like Oda's other changes. This page covers when Oda uses code, how it runs, when it asks, and what it never does.

When Oda writes code

How the code runs

  1. The code runs in a sandbox, a separate, locked-down space inside the pane. It has no network access and cannot reach your sign-in, your chats or the files the pane stores.
  2. The code never touches Excel itself. Each time it syncs, it hands the pane a list of what it wants to read and change.
  3. The pane checks every item against what this version of Excel offers, the list of what Oda never does and the same formula checks as Oda's other steps. If anything fails, nothing of that sync runs.
  4. The pane works out what the sync changes, decides by your permission mode whether to ask, and only then makes the change in Excel.

The code can call Oda's read steps, such as reading cells or searching the workbook, up to 50 times in one run. Changes the code made appear in the Changes panel under Oda's reply, like any other change.

When Oda asks

What the code doesAsk before editsAccept editsSkip all permissions
Reads the workbookRunsRunsRuns
Changes only sheets the same code added, such as filling, formatting or charting a new sheet, or deleting it againAsksRunsRuns
Any other change that removes nothing: cells of a sheet the code did not add, even cells Oda wrote, or the workbook's defined namesAsksAsksRuns
Changes how Excel calculates, such as switching to manual calculationAsksAsksRuns
Deletes, clears or removes anything on a sheet the code did not add, moves or fills cells there, makes a change there that no other step makes, or makes a workbook-wide change only code makes, such as to a cell style or the document properties. The card shows such a change as Changes made by Office.js code (Excel.Shape.delete) on Logo that Oda cannot describe exactlyAsksAsksRuns
Puts a link on cells, to a web address or a place in the workbookAsksAsksAsks
Something Oda never does, listed belowRefusedRefusedRefused

So in Accept edits, a sync runs without a card only when every change in it lands on sheets the same run of the code added, or on charts, tables, rules and shapes it made there. Copying your cells onto such a sheet counts, as it only reads them. A chart there that takes its data from one of your sheets asks, and so do pivot tables, slicers, defined names and styles. A table whose address names no sheet asks as a change Oda cannot describe exactly, because Excel puts it on the sheet that is active. Cells Oda wrote earlier do not count as the code's own: changing them asks, too. Once the code moves your cells onto a sheet it added, no sheet counts as new for the rest of that run. When one sync makes several changes, one card lists them all and asks as the strictest of them would. See Permission modes and approvals in Excel.

The approval card for code

A card for a sync of code takes the place of the message box and shows:

Answer with Allow, Don’t allow, or one of the answers under More ways to allow, the arrow beside Allow:

A card for a large or structural change can offer a snapshot sheet first, as other cards do. If what the sync changes is edited while the card waits, nothing of that sync runs, even after Allow.

What the code never does

Oda's code is refused, in every permission mode, when it tries to:

Such a step shows Oda’s code asked for something Oda never does, so nothing of that step ran. A step that uses something your version of Excel does not have shows Oda’s code used something this Excel does not have, so nothing of that step ran.

Limits

ItemLimit
Running time90 seconds; time waiting for Excel, Oda's read steps or an approval card does not count
One run in all10 minutes, not counting the time approval cards wait
Syncs in one run200
One sync10,000 steps, 50,000 written cells and 3 MB of steps
What the code returns40,000 characters

A run that does more shows Oda’s code did more at once than one run may., and one that runs past its time shows This took too long and was stopped. Stop ends the code at once, and a card that is still waiting is answered Don’t allow.

Undo what the code changed

Revert turn treats the code's changes as it treats the same changes by Oda's other steps: it puts back cell values the code wrote. A turn in which the code made a change only code makes, or a change Revert turn cannot undo for other steps either, is refused, and nothing is changed. Use Ctrl+Z where it works, a snapshot sheet, or ask Oda to change it back. See Review and undo Oda's changes.

Where Office.js code is available

Oda writes code only when all of these hold:

When the setting goes off while you work, Oda stops offering code, and a code step that was already on its way shows This tool was turned off for Oda in Excel, by your company or in your settings.

Questions, answered

Why did Oda write code instead of using its normal steps?

None of its other steps could do the task, for example a chart or shape setting they lack, or many small edits at once. Oda prefers its other steps whenever one fits.

Does the code change my workbook directly?

No. The code runs apart from Excel, in the pane's sandbox. The pane checks each batch of changes the code asks for, asks you where your permission mode says so, and only then makes the change.

Can the code reach the internet or my files?

No. The sandbox has no network access and cannot reach your sign-in, your chats or the pane's stored files. Links the code puts on cells always ask, in every permission mode.

What does Allow the rest of this run cover?

The later changes of the same code that remove nothing, until the code ends. Removals, links, changes to how Excel calculates and changes only code makes still ask, and the next piece of code starts asking again.

Why does a code card ask in Accept edits?

The code changes something outside the sheets it added: cells of your sheets, even cells Oda wrote, the workbook's names, styles or document properties, or how Excel calculates. Or it removes something, or makes a change none of Oda's other steps makes, which counts as a removal. Only changes to sheets the same code added run without a card. A link always asks.

Why did code that built a new sheet run without a card?

Every change it made landed on a sheet the same code added, so nothing of yours changed. In Ask before edits such code still asks.

Why does a code card not offer Always allow in this chat?

The card removes or deletes something on a sheet the code did not add, moves cells there, puts a link on cells, makes a change there that only code makes, changes how Excel calculates, or makes a workbook-wide change only code makes, such as to a cell style or the document properties. Each of those is asked separately. A card that removes, links, changes how Excel calculates or makes a change only code makes offers only Allow and Don’t allow, with no More ways to allow.

Can I turn Office.js code off?

Yes. Open Settings from More options in the pane header and turn off Office.js code under What Oda can use. Your administrator can also turn it off for the whole company.

What happens if I click Don’t allow halfway through?

Nothing of that sync runs and the code stops. What earlier syncs changed stays, and the Changes panel lists it.