Search code examples
htmlapihttpxlsxjsreport

html-to-xlsx jsreport recipe with initial xlsx template file - HTTP API request


I try to generate xlsx-to-html recipe report with JsReport HTTP API https://jsreport.net/learn/api and initial attached xlsx template.

The documentatio is missing how to build request body to pass additional xlsx file like in bleow examples:

I tried to add in template object following object:

template: {
   ...
   engine: "handlebars",
   recipe: "html-to-xlsx",
   xlsxTemplate: {
      content: "base64_string_of_template_xlsx_file_........."
   }
   ...
}

but with no success.

How should be constructed JSON body for this request?


Solution

  • I managed to find proper json that is consumed properly by JsReport:

    {
       "Template": {
          "Content": "template def string..",
          "Recipe": "html-to-xlsx"
          "Engine": "handlebars",
          "BaseXlsxTemplate": {
             "Content": "base-template-string-encoded-as-base64",
          },
          "HtmlToXlsx": {
             "InsertToXlsxTemplate": true, 
             "WaitForJS" = false,
             "HtmlEngine" = "chrome"
          }
       },
       "Data": "Json data...",
       "Options": {...}
    }