跳转到主要内容

previewJson()

function previewJson(
templateBuffer,
sourceJson,
options?): Promise<PreviewResult>;

Defined in: impl/js/src/index.ts:480

Preview what convertJson will produce without generating full files (ADR-0075). JSON sources surface with sentinel coordinates (sheet = source name, table = "(json-source)") since they have no workbook location.

Parameters

ParameterType
templateBufferArrayBuffer
sourceJsonXl3SourceJsonInput
options?ConvertOptions

Returns

Promise<PreviewResult>

Stable

Added in XTL 1.x (ADR-0075); additive to the frozen preview.

Example

const result = await previewJson(templateBuffer, {
version: 'xl3-source-json/0.1',
sources: {
default: { headers: ['Customer', 'Amount'], rows: [['Acme', 100]] },
},
});
console.log(result.files, result.warnings);