Skip to content

Sample-data library

DOCX and XLSX templates can carry one optional JSON dataset alongside their report schema. Word Settings can import or locally generate a candidate, validate it, and explicitly save it in the document. The add-in sends no sample, schema, or document content to the reporting API. XLSX has library/API support; no Excel add-in is required.

DocxTemplate and XlsxTemplate expose the same operations:

template.AttachSchema(ReportSchema.FromJson(schemaJson, "sales", "1"));
template.AttachSampleData(sampleJson); // Validates before replacing.
JsonElement? sample = template.ReadSampleData(); // Null means absent; JSON null remains a value.
template.RemoveSampleData(); // Keeps schema, content, and bindings.

ReportSampleData.Infer(json) returns a 2020-12 JSON Schema. ReportSampleData.Generate(schemaJson) returns random JSON, validated against the input schema. Both live in ISE.Reporting.Core.Schemas; generation is the same implementation in the service and browser WASM host.

Sample data uses a custom XML part rooted at reportSampleData in http://schemas.iseag.ch/reporting/sample-data/2026, containing escaped JSON text. The store marker is {A6E4F028-53B9-49BA-83A9-C824F937D685}; the namespace also identifies parts written by Office.js. It is separate from schema storage. Duplicate or unreadable samples require explicit replacement/removal. Replacing a schema revalidates retained samples and rejects mismatches before changing the schema.

Fill strips the sample attachment from the returned copy in both engines and retains it on the source template. Fill always uses explicitly supplied data. Removing an attachment does not erase values already present in visible content or cells.

All routes require the existing X-API-KEY and rate limits. /api aliases are pinned to /api/v1.

POST route Request Response
/api/v1/sample-data/generate Raw JSON Schema, application/json Raw generated JSON
/api/v1/schema/infer Raw JSON sample, application/json Raw JSON Schema
/api/v1/docx/schema/infer Multipart DOCX and JSON Updated DOCX
/api/v1/xlsx/schema/infer Multipart XLSX and JSON Updated XLSX

Multipart fields: file (one template), data (JSON text), id, version, optional title, attachData, and removeData. New schema attachments require ID/version; replacements preserve unspecified identity values. attachData=true explicitly replaces the existing sample with the submitted JSON. removeData=true explicitly removes it. Both flags default to false and cannot both be true. With neither flag, retained sample data must validate against the inferred schema. A mismatch returns 422; no partially modified file is returned. These operations attach metadata without filling the template or changing its formulas/bindings.

Malformed JSON yields 400, oversized requests/packages 413, and unsupported generation or invalid attachments 422. Errors use Problem Details. JSON is limited to 4 MiB and 64 levels; numeric values must fit JavaScript’s safe range. Attachment endpoints use the existing DocxFill file/deadline settings for both formats and cap expanded packages at 64 MiB / 10,000 entries.

Generation supports named/nested objects, homogeneous arrays, scalar types, nullable single-type unions, enums/constants, nonrecursive local JSON-pointer references, numeric bounds and positive decimal multipleOf steps (including currency increments such as 0.01), string-length and array-length bounds, and date/date-time. Multiples respect inclusive/exclusive bounds and integer types; impossible ranges fail explicitly. Decimal steps and their multiplier range must fit .NET decimal arithmetic. Optional fields are populated; unconstrained arrays contain a small number of items. Limits: 10,000 generated nodes, 24 levels, 100 items per array, 4,096 characters per generated string, and 4 MiB output. Unsupported constraints (including compositions, patterns, unique items, and reference siblings with constraints) fail with a path-specific message. No remote references are fetched and no schema is weakened to permit a result.

Inference merges properties across observed objects and preserves nullable types, without guessing requiredness, enums, or formats. Empty arrays and incompatible item shapes remain permissive. An inferred schema describes only the observed sample and can be replaced by an authored contract.

The shared generator uses small built-in lists, with no faker dependency or network requests. Property names are matched without case or separators, including through local references and array items:

Property names (examples) Generated value
FirstName, first_name, GivenName, Vorname A first name, such as Emma
LastName, Surname, Nachname A surname, such as Keller
Name, FullName, DisplayName A full name
City, Town, Wohnort A city, such as Bern or Paris
Country, CountryName, Land A country name
Nationality, Nationalität A nationality, such as Swiss or Italian
BirthDate, DateOfBirth, DOB, Geburtsdatum A date between 1 and 85 years ago
Note, Notes, Description, Comments A short Lorem ipsum passage
CompanyName, Product, Month A company, product, or month name
Image.Data, Images[].Data (also Avatar/Picture) A random 56×56 PNG pixel avatar as a data:image/png;base64,... URL

These are independent illustrative values, not coherent identities or matched addresses, and there is no locale dataset. A bare Name is treated as a person’s display name; use CompanyName or an enum when that would be ambiguous. Enums/constants and explicit formats take priority. Birth dates use ISO dates by default and honor explicit date/date-time formats. Length limits filter the lists; when no realistic value fits, generation falls back to an ordinary bounded string. Lorem ipsum respects length limits and normally ends at a word boundary. Unrecognized fields retain the generic generator.

Numeric names also provide sampling preferences: Quantity/Qty use whole counts from 0–20; Count, OrderCount, and Stock use 0–100. Price, UnitPrice, and Cost use decimal amounts from 1–500 with up to two decimal places, while Amount, Revenue, and Total prefer 100–1,000. These preferences apply only where the schema permits them: explicit bounds, enums, types, and multipleOf win. If the preferred range or precision cannot satisfy the schema, generation uses its permitted values instead. Values are independent; totals are not calculated from quantities and prices.

Declare prices as {"type":"number","multipleOf":0.01} to require cents in all data, and quantities as {"type":"integer","minimum":0} to require whole, nonnegative quantities. The generator will preserve an explicitly declared integer type even on a property named Price.

Image hints apply to Data inside an image-named object, including through local references and array items; unrelated Data fields are unchanged. Each avatar has a random color and mirrored 5×5 block pattern with a light border. Its PNG is encoded locally using built-in compression, with no imaging dependency, service, or network request. Unconstrained sibling ContentType, Name, and AltText fields receive image/png, Sample avatar, and Generated pixel avatar. Explicit enum/const values and formats still take precedence. Image data is never truncated: incompatible length bounds produce a field-specific error. The data URL can be used directly by the report’s picture bindings.

The PNG encoder adds 2,560 raw bytes / 1,364 Brotli-compressed bytes to the Core WASM asset, with no new package dependency. An inspected generated PNG was 178 bytes. Verification passed 49 focused generator/API tests and three browser regressions, including real browser PNG decoding, symmetry checks, and embedding generated PNG bytes in a native picture control through the WASM report engine. Typecheck, lint, and the production/WASM build also passed.

Measured in the Release WASM build, the string and numeric hints grew the active ISE.Reporting.Core asset from 71,957 to 80,149 bytes raw (+8,192), or from 27,679 to 30,868 bytes with Brotli (+3,189). The numeric hints account for 776 of the added compressed bytes. No package dependencies were added. The 47 focused generator/API tests passed, as did typecheck, lint, and the production/WASM build. Browser regressions also check integer quantities and decimal unit prices using the published schema.

  • API suite: 126 tests passed, including generation, inference, both attachment formats, retained-data conflicts, identity preservation, and filled-copy sample removal.
  • Add-in: typecheck, lint, production/WASM build, and 120 unit tests passed. The saved tests/browser/sample-data.spec.ts regression passed against the local add-in with real WASM generation; it checks candidate cancellation, attachment removal, and zero reporting API requests.
  • playwright-cli at https://localhost:3000/addin/?mock: imported and attached JSON, generated locally, canceled a candidate, and removed the attachment without reporting API requests.
  • Desktop Word through computer-use: imported and attached synthetic JSON, generated and applied a replacement, saved and closed the DOCX, reopened it and confirmed the data and persistence choice were restored. Preview opened a separate copy whose Settings showed no attached sample; the source retained its sample. Inspection of the saved DOCX confirmed separate schema and sample custom XML parts.

One full API run and one concurrent add-in run initially hit existing/default test time limits. Their isolated reruns and subsequent complete suites passed.

The multipleOf follow-up adds the published sample-schema.json as a regression fixture. All 30 focused API/generator tests and 121 add-in unit tests passed, along with typecheck, lint, the rebuilt production/WASM bundle, and both browser regressions. The schema-specific browser test generates and applies five successive datasets, including decimal currency values.