Convert report to XLS using jsreport.render and authentication

  • Currently in our HTML report we have a button to generate the report in XLS, the button uses the function listed below. The issue is that we use Authentication so we need to set the token in the header in order for it to work. Is there a way to not hardcode the token in the function?

    function toXLS() {
    jsreport.headers['Authorization'] = "Basic xxxx==";
    template: {
    content: document.getElementById('printedArea').innerHTML,
    engine: "handlebars",
    recipe: "html-to-xlsx",
    data: '{{}}'
    }).then(r =>'report.xls')).catch(console.error);

  • Its usually better to route the request through your server part.
    So on the front end you gonna call some fetch to reach your server and on server you make a server side call to the jsreport server and return back to the client.

Log in to reply

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