Course contents8 lessons
Course overview
  1. Create an API based application
  2. Set inputs and outputs using API toolkit
  3. Input randomization
  4. Batch run
  5. Save data
  6. Formula auditing using Excel Export
  7. 07Document creation
  8. 08Export to Postman

Lesson 7 of 8

Document creation

Generate PDF or Word documents from an API request by mapping Word-template placeholders to workbook inputs and calculated outputs.

2 min read

Generate a personalized PDF or Word document as part of a SpreadsheetWeb API calculation. This is useful when a calling application needs a quote, proposal, report, or other customer-facing document that combines static language with workbook inputs and calculated results.

Prepare the Word template

Create the document layout in Microsoft Word. The template can contain ordinary text, formatting, legal language, and other fixed content.

Insert placeholders for dynamic values using double curly brackets. Each placeholder represents a document stub that will be mapped to a named range in the Excel workbook. In the insurance example, the template includes customer inputs such as issue age and coverage amount along with the calculated total premium.

Using the same names for Word placeholders and Excel named ranges makes the mapping easier, but it is not required.

Create the Print Process

  1. Open the API application in Design and start a new transaction.
  2. Go to Events and add a Print Process.
  3. Give the process a descriptive name, such as Proposal.
  4. Choose PDF or Word as the document output format.
  5. Create the process, then add a document and upload the Word template.

After the template is uploaded, open its document stubs. SpreadsheetWeb lists the placeholders detected in the Word file and the named ranges available in the workbook.

Map placeholders to workbook values

Map each document stub to the input or output that should replace it at runtime. When a placeholder and named range use the same name, SpreadsheetWeb can match them automatically. Otherwise, select the correct named range manually.

Enable the required stubs and publish the transaction. The published API version now includes the document-generation process.

Generate the document through API Toolkit

Open API Toolkit and select the newly published transaction. The request settings now contain a Print Process section.

  1. Add the configured process to the calculation request.
  2. Supply the required workbook inputs.
  3. Select Calculate.
  4. Open the document URL returned in the print section of the response.

SpreadsheetWeb calculates the workbook, replaces the template placeholders with the submitted inputs and calculated outputs, and generates the requested document. The consuming application can use the returned URL to retrieve and present the file to the user.