API to set Excel template



  • For a report using an Excel template, is there an API call to set/update the excel template file?


  • administrators

    yes, you will need to first insert the excel template and then update your main template (that uses xlsx recipe) to use the new created xlsx template.

    (assuming that your jsreport server is started on localhost and port 5488)

    to insert the excel template you can do a POST json request to http://localhost:5488/odata/xlsxTemplates with the following body:

    {
      "name":"demo", // the name of your xlsx template
      "contentRaw":"UEsDBBQABgAIAAAAIQA7SI5AaQEAAMQE..." // the content of the xlsx file in base64 encoded string
    }
    

    this call will return a shortid property in the reponse, you will need that in order to update your main template.

    then to update the template (the one that have the xlsx recipe) you can make a PATCH request to http://localhost:5488/odata/templates(gx4cQ2WOrlStm6hD) (where what is inside the () is the _id of your main template) and include in the body something like this:

    {
     ...other properties of your main template here...
     xlsxTemplate: {
       shortid: 'put here the shortid that was returned from the first post request'
     }
     ...
    }
    


  • Perfect thanks


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.