Synchronisation exchanges data between the Excel workbook and the facts database. It consists of two directions that can be executed separately or combined:
- **Upload**: send all [[Invantive Control for Excel/Concepts/Pending Change|pending changes]] to the facts database;
- **Download**: retrieve the current facts from the database and refill the [[Invantive Control for Excel/Concepts/Block|blocks]];
- **Synchronize** (both): first upload, then download, so the workbook ends up reflecting the database state including the just-uploaded changes.
Synchronisation is started from the [[Invantive Control for Excel/User Interface/Control Ribbon|Control Ribbon]], from worksheet formulas (`I_SYNC_ALL`, `I_SYNC_DOWNLOAD`, `I_SYNC_UPLOAD`) or from VBA.
## Execution Order
Blocks are processed in the download order respectively upload order defined by the modeler. Around each step the applicable [[Invantive Control for Excel/Concepts/Extension|extension]] events fire:
1. model event "before synchronisation";
2. upload: per block in upload order: "before upload" event, generated or instead-of DML statements, "after upload" event;
3. download: per block in download order: "before download" event, query execution with [[Invantive Control for Excel/Concepts/Parameter|parameter]] filters applied, block refill, "after download" event;
4. model event "after synchronisation".
During refill a block first rolls up its previous contents and then expands again to fit the newly downloaded rows. Formulas that reference fixed cell positions inside a block therefore break; use the block's named ranges with `INDEX`, or [[Invantive Control for Excel/Concepts/Column Expressions|column expressions]] in expression fields, instead.
## Removing Downloaded Facts
"Remove Downloaded Facts" empties all blocks without uploading anything. Use this before distributing a workbook when recipients must not see the downloaded data, or to reduce file size. The model itself stays intact; the next download refills the blocks. Publishing a workbook (see [[Invantive Control for Excel/User Interface/Control Ribbon|Publish]]) offers a controlled variant of this for distribution.
## Recalculation and Caching
After logon and after each synchronisation, the Invantive worksheet formulas are recalculated. Query results used by formulas can be cached per combination of parameter values to keep recalculation fast. Whether downloaded data is real-time depends on the data container: on-premises databases are typically queried live, while cloud platforms are often served from a cache to respect API rate limits. See [[Invantive UniversalSQL/Invantive UniversalSQL|Invantive UniversalSQL]] for caching concepts.
## Batch Changes
For bulk operations from VBA the mode mechanism (`I_START_MODE` / `I_END_MODE`, or [[I_StartAtRiskMode]] / [[I_EndAtRiskMode]]) temporarily suspends per-cell change registration; changes are registered when the mode ends. This substantially speeds up macros that write many cells.