swexcel

Windows workbook build and first integration checkpoint

This checkpoint targets Windows 64-bit Excel for Microsoft 365. It generates a macro-enabled workbook from the reference sheet specification and imports the current VBA modules. It does not validate all 106 native functions or complete the full API workbook product.

The original spreadsheet is preserved. This workflow creates SWExcel.xlsm inside a prepared rework/dist/SWExcel-<VERSION> package. No Windows VM, Parallels session or Excel process is launched by the macOS preparation step.

Requirements

Use a clean test user profile or a dedicated test Excel process. The builder creates its own Excel COM instance, closes that workbook and quits that instance; it never kills all Excel processes. Microsoft’s desktop Office automation requires an interactive user session; running as a service/SYSTEM task is not an equivalent acceptance environment. Office automation limitations.

Prepare and build

From the repository root, prepare the package using the project Python command:

python3 rework/tools/prepare.py

For this checkpoint VERSION is 0.1.0-dev.4, so the prepared folder is rework/dist/SWExcel-0.1.0-dev.4. The prepared package is source and runtime assets, not a Windows-built .xlsm.

On Windows, open the x64 Native Tools Command Prompt for Visual Studio with the C++ build tools installed. Change to the prepared package folder, start PowerShell from that prompt so it inherits the compiler environment, and build the pinned DLL before building the workbook:

Get-Content .\VERSION
.\tools\build-engine.ps1 -OutputRoot .\runtime\engine
.\tools\build-workbook.ps1 -PackageDirectory .

The engine build compiles release v2.10.3bfinal, source commit f4dcd18e8005dde95fd8a8d2312ed12f9accd1b0, and writes the DLL, swetest64.exe and runtime/engine/build-provenance.json. It requires cl.exe and dumpbin.exe; it does not install a compiler. The workbook builder refuses to proceed without source-build evidence matching the pinned commit, version and source-manifest hash, the actual DLL hash/size, and the exact 106-symbol catalog. A staged published DLL alone cannot pass this gate. Source compilation remains separate from DLL call and Excel acceptance.

The pinned swetest.c has an undeclared fp in its Windows printing branch. The builder corrects exactly that statement to fputs(info, stdout) in build/engine-x64/swetest-console.c, preserving the vendor tree. swetestConsoleFix in build provenance records the original and compiled source hashes; engine compilation units are unchanged.

The script writes SWExcel.xlsm, exports imported modules into a fresh evidence/<UTC-run-id>/vba-export directory, and writes evidence/<UTC-run-id>/build.json. evidence/build.json is the latest build report. VBA source and export hashes are recorded; parity ignores VBE attribute lines, line-ending differences, trailing whitespace and identifier casing. String literals and comments remain case-sensitive. Unexpected source changes fail the build.

The generated workbook starts on Welcome and includes Setup, Function Catalog, Bodies, Options, Diagnostics, Integration, and clearly labeled pending example/roadmap sheets. All 106 catalog symbols are listed as native inventory; unimplemented worksheet interfaces remain pending. The workbook stores formulas with Formula2. Ordinary UDF calculations during construction/opening are not a recorded smoke test. Without -RunIntegration, the check table remains PENDING, the report says not_run, and compilation/runtime acceptance remains unverified.

The builder refuses to overwrite an existing workbook. Preserve a previous package or choose a different .xlsm filename in the same package root:

.\tools\build-workbook.ps1 -PackageDirectory . -OutputWorkbook SWExcel-review.xlsm

If a script is blocked by the Windows execution policy, use your approved developer policy or administrator guidance; this workflow does not silently change the policy.

Explicit integration run

To create a new workbook and execute the first smoke checkpoint, use:

.\tools\build-workbook.ps1 -PackageDirectory . -OutputWorkbook SWExcel-tested.xlsm -RunIntegration

Alternatively, after opening a generated workbook in Excel with trusted macros enabled, invoke SW_RunIntegrationChecks from the VBA Immediate window:

? Application.Run("'SWExcel.xlsm'!SW_RunIntegrationChecks")

This is a Function, so it may not appear in Excel’s ordinary Macros list. A successful summary is PASS=<count>;FAIL=0. The macro populates Integration and records Excel version/build/OS, the architecture probe, workbook path, runtime data folder and the runtime’s actual verified native-module path. A fatal error produces a failed check. It does not run automatically when the workbook opens.

The command-line run additionally records these actuals in evidence/<UTC-run-id>/integration.json and in the build report, including failed summaries. A failed run retains the saved workbook and build evidence and returns a failing command. A failure before the macro produces a summary is recorded in build.json. A manually executed macro changes the workbook sheet; it does not create an external JSON report, so preserve/save that workbook as evidence.

Checkpoint assertions cover:

The first checkpoint covers seven calculation/name/calendar helpers plus three diagnostic worksheet functions (SW_RUNTIME_STATUS, SW_ENGINE_PATH, SW_DATA_PATH). It is not full API runtime coverage. Successful import/export does not mean VBA compiled; an executed smoke macro establishes only its compiled/executed path. In the VBE, separately run Debug → Compile VBAProject, record its result, then save and reopen the workbook in a fresh Excel process.

Desktop acceptance beyond the smoke suite

Record the package version, source/DLL hashes, expected upstream runtime version, Excel build/channel, host architecture and test date. These checks remain separate, explicit acceptance work:

  1. Open/recalculate/save/reopen the complete package in a fresh Excel process. Compare worksheet output, actual flags and numerical reference fixtures.
  2. Move the complete package to a new local folder, including a path with spaces. Confirm actual loaded-module/data paths move with it. Test non-ASCII paths separately; Unicode DLL loading does not prove the engine’s data-path encoding behavior.
  3. Test missing/wrong-architecture DLLs, missing data, and a different same-named DLL already loaded in the test Excel process. Errors must be actionable; do not replace modules in a production Excel session.
  4. Test simultaneous workbooks with different options and copies in different folders. Verify collision handling and no silent cross-workbook engine/options reuse.
  5. Edit formula inputs and options, test ordinary recalculation and full rebuilding, check dependent formulas, block/unblock a spill and measure a representative batch calculation. VBA UDF execution is single-threaded. Excel performance guidance.
  6. Download the actual release archive into a clean Windows profile and test extraction/onboarding. A local developer copy without internet markings is not download acceptance.

Spilled formulas belong in the worksheet grid outside Excel Tables. Formula2 avoids implicit-intersection behavior associated with older formula APIs. Formula2, spill rules.

Downloaded macro onboarding

Windows Microsoft 365 may block downloaded macros because the workbook has Mark of the Web. The red risk banner has no Enable Content button. After verifying that the package and source are trusted, Microsoft documents file Properties → General → Unblock, then reopen the workbook. Organizational policy or Trust Center settings can still block macros. Do not instruct users to enable all macros or make their Downloads folder globally trusted.

Signed VBA with an already trusted publisher is another deployment path; signatures and publisher trust must be actually established and tested before advertising that experience. The ordinary user need not enable Trust access to the VBA project object model. Microsoft’s documented macro-download behavior.

Evidence boundaries

After closing Excel and writing its reports, the workbook builder refreshes package-files.json with hashes and sizes of the complete current package, including workbook, engine build artifacts and evidence; the inventory excludes itself. package-manifest.json retains provenance for the initially staged published reference DLL. For the fresh Windows build, runtime/engine/build-provenance.json and the current file inventory record the authoritative DLL hash. A current inventory is integrity evidence, not public-release acceptance.

Repeatable desktop acceptance

Run tests/test-vba-normalization.ps1 on Windows for the builder parity regression. After building the workbook, run tests/test-excel-acceptance.ps1 -PackageDirectory . -Workbook SWExcel.xlsm -OutputDirectory C:\SWExcel\acceptance-new-run with a new output directory. This opens dedicated Excel instances, uses disposable runtime/workbook copies for failure and relocation tests, and preserves a JSON report. It also creates a peer workbook in the package for same-package state isolation. General formatting is read from a blank Excel cell, so non-English installation formats are supported. VBE compile and downloaded-archive onboarding remain separate gates.

Full API development verification

After granting VBA-project access for a developer build, run tools/compile-workbook.ps1 -Workbook <absolute XLSM> -Report <JSON>. It invokes Excel VBE command 578, checks that compilation becomes disabled, then saves. It never changes Trust Center settings. The current automated session temporarily enables AccessVBOM only under the user’s explicit authorization and restores the previous value in finally; ordinary users do not need this setting.

Generate build/native-api-probe.c with python tools/generate_native_probe.py. Compile it as x64 C with MSVC and vendor/swisseph on the include path. Run the resulting executable with three arguments: absolute package DLL, ephemeris directory, and output JSON. This typed C caller checks all 106 exports and buffer canaries. Use that Windows JSON with tests/test-full-api.ps1 -PackageDirectory <path> -Workbook SWExcel.xlsm -Reference <JSON> -Report <JSON>; it checks native returns, outputs, and actual command entry points. tests/test-api-regression.ps1 exercises helper/calendar/state/error cases and all 95 live worksheet examples. Run the original desktop acceptance suite as well.

The separate macOS reference runner is useful for cross-platform comparison; platform differences in the pinned engine’s fixed-star radial speeds must not be hidden by widening all numerical tolerances. Windows VBA comparisons use the same Windows DLL through an independent C caller.