Skip to content
SheetForge

References across workbooks

A tab in one workbook can reference a tab in another. This page covers how those references are written and validated, and what reflect, Export, Push and import do when workbooks depend on each other.

Reference notation

Every kind of reference may point across a workbook boundary, in the same notation it uses inside one workbook:

  • RecordId@Tab
  • IntId@Tab
  • LocRef@Tab
  • A plugin type with reference parity
  • Enum<Name>, for an enum defined in another workbook's enum sheet

Nothing marks a reference as foreign. The tab name says everything, because tab names are unique across the project.

Validation

Validation sees the other workbook. A key that does not exist there is the same structured error it would be inside one workbook, with the same nearest-match suggestion.

All of these read the other workbook's tabs:

  • Problems
  • The cell tooltips
  • The reference pickers
  • The typo suggestions

Inactive workbooks

A workbook outside the active set is checked against its last import. Its baseline snapshot stands in for it. The relation hints in the workbook lists say so.

References that cannot be checked

A workbook that has never been imported has nothing to check against.

A snapshot that cannot be read, is empty, or failed its own validation makes every reference into it a ReferenceTabUnverified warning. The warning means the reference was not checked. It does not mean the reference was confirmed.

To clear the warning, import that workbook, then import this one again.

Plugin validators

Plugins see the other workbooks too. A domain validator receives the other workbooks' tabs as a read-only lookup. The lookup is ReferenceTables and ReferenceKeyIndices on the validator's context.

A plugin rule therefore does not mistake a valid cross-workbook reference for a broken one. Tabs from other workbooks shows how a validator reads them.

Renames

Renames propagate across workbooks, in both views. Renaming a record key, a tab or an enum rewrites the referencing cells in other workbooks too.

The confirmation dialog lists the affected cells per workbook.

Reflect into several workbooks

To reflect is to write your staged edits to their sources. Press ↑ Send in the Data Studio toolbar. It writes each staged edit to the source of the tab it belongs to. Push is a different action, covered under Export and Push scope.

When the staging touches tabs of more than one workbook, the reflect is split into one slice per workbook. The slices run in dependency order. The workbook that is referenced is written before the one that references it. A renamed key therefore exists before the cells that use its new name are written.

A reflect that touches a single workbook is an ordinary reflect. It shows the same dialogs in the same order, followed by the same automatic re-import.

Confirmation and approval

One confirmation lists the workbooks and how many changes each receives.

A Google workbook then shows its usual diff approval, per slice. The approval is titled with the workbook and its place in the sequence.

When a slice fails

A failure stops the sequence.

SliceState after the failure
Already writtenCommitted, and its undo history is cleared
FailedStays staged
Every slice after the failed oneStays staged

A dialog says which slices were written, which failed and which were not attempted. Fix the cause and reflect again.

Caution

A reflect that spans workbooks is not atomic. Workbook map and limits describes what a failed slice leaves behind.

Export and Push scope

The Data Studio's ⚙ Settings has an Export and Push apply to choice:

  • The open workbook, which is the default
  • All active workbooks

Export writes baked values back into sheet files. Push sends baked values to a live Google sheet, cell by cell. With All active workbooks, these two commands cover the whole active set.

CommandWhat it does
The settings Inspector's Run Export, or SheetForgeActions.RunExport()Exports every active workbook and reports one summary. The workbooks set to Excel go into one book together
Push to Google Sheet, in the toolbar's Google Sheets dialogAsks once in its scope dialog and lists the workbooks it will push

The Push prompt also names the workbooks it will skip and why. It skips a workbook whose source is not Google Sheets, and one that is blocked. Push continues past a failure, because workbooks are independent.

The toolbar's Download ▾ menu is not governed by this choice. It writes the sheets you pick in it, from whichever workbook they belong to.

Reflecting is not governed by this choice either. It always writes to every workbook that has pending edits.

Recheck after an import

Importing a workbook can break references that other workbooks hold into it. A deleted record, a renamed tab or a removed enum member does that.

Every import therefore ends with a recheck. The recheck covers every workbook that references the imported one, whether it referenced it before the change or references it after.

The block that follows

A workbook whose references are now broken gets a block, and the Console reports it. The block stops that workbook's Export, Push and player builds until the references are fixed and it is imported again.

The reason names the workbook the broken references point into. The Data Studio and Getting Started show the same block.

The block and the validation state

The block is separate from the workbook's own validation state:

  • It is recorded per causing workbook, the one whose import broke the references.
  • It is cleared on its own when the blocked workbook is imported again and its references are found whole.
  • It never touches the quarantine mark that a failed import of the workbook itself leaves behind.

Open a sheet that failed validation describes the quarantine mark.

The recheck only reads

The recheck only ever reads. Nothing is re-imported on your behalf.

When the referencing workbook cannot be checked at all, an existing block is kept rather than lifted. Not being able to check is not the same as being whole.

Enums another workbook uses

A sheet-defined enum becomes a C# type, and another workbook's generated code may use that type. Each of these changes would leave that other code pointing at something that no longer exists:

  • Renaming the enum
  • Moving its owner's generated namespace or folder
  • Changing a member's value or the underlying type

Because each workbook normally compiles in its own import cycle, one of the two workbooks would break in the middle of such a change.

Joint import

SheetForge therefore runs the affected workbooks as a joint import. A joint import does this, in order:

  1. Fetches all of the workbooks.
  2. Validates each against the others' newest sheets.
  3. Generates code for all of them.
  4. Compiles once.
  5. Bakes all of them after the reload.

The Console says which workbooks are imported together and why.

A workbook joins the group even when it is not active, because compilation safety needs it. A workbook already imported as part of a group is skipped later in the same batch.

Rename or move an enum

A rename or a move finishes in one cycle when the referencing sheets already use the new name. The Studio's rename propagation writes the new name for you.

Delete an enum

A deletion stops as long as a referencing sheet still uses the old name.

WorkbookReports
The one that still uses the old nameUnknownEnumName
The ownerHeldByCoupledWorkbook

The owner is held because generating the owner alone would break the other's compilation.

Nothing is generated for any member of the group until every member validates. The sheets are still saved and open in the Studio for fixing, as after any failed import.

Enums with an unknown owner

Generated code may use an enum that this import changes. When SheetForge cannot tell which workbook that code belongs to, such as on a fresh clone with committed code and no import history, the import is held with HeldByCoupledWorkbook.

The import asks for one Pull every workbook, which records which workbook owns each enum.

Generated code across workbooks

Reference fields are generated as RecordRef and IntRef, whichever tab they point at. A workbook's generated code therefore never depends on another workbook's classes.

Enums are the one exception. The generated files are laid out to keep that dependency legal.

By default, workbooks share one generated-code folder and one namespace. In that layout, the generated files look the same as in a project with a single workbook.

Shared enum files

SheetForgeEnums.cs in a generated-code folder holds the enums of every workbook that generates into that folder. It has one namespace block per owning workbook.

A column typed with another workbook's enum is generated with that enum's full name.

SheetForgeLocalizationKeys.cs follows the same rule for localization key constants.

What the shared files are written from

Both files are written from the definitions each workbook last generated. They are not written from whatever its latest import saved.

A workbook whose last import failed or is being held therefore does not leak an unfinished enum into another workbook's build.

Workbooks in different folders

Two workbooks may generate into different folders while one uses the other's enum. The companion assembly definition of the using folder then references the owner's assembly.

Two generated-code folders that use each other's enums cannot both reference each other, because their companion assemblies would form a cycle. That import fails with EnumAssemblyCycleAcrossWorkbooks. The error asks you to point the workbooks' generated code folders at the same folder.

Next steps