How preview docx in myself web site?



  • How preview docx in myself web site which docx generate from jsreport server?
    I set it like below, but it always download to my local.

     jsreport.renderAsync(printCommand).then(function (res) {
                var placeholder2 = document.getElementById("reportPlaceholder");                
                var iframe = "<iframe type='application/vnd.openxmlformats-officedocument.wordprocessingml.document' frameborder='0' src='" + res.toObjectURL() + "' style='width:100%;height:100%;'></iframe>";
                placeholder2.innerHTML = iframe;
                if (successCallback) {
                    successCallback(res);
                }
            }, function (error) {
                if (failCallback) failCallback(error);
            });


  • See the last chapter here
    https://jsreport.net/learn/office-preview

    You probably want to render the request like this

    { 
      "template": {...},
      "data": {...},
      "options": { 
        "office": {
           "preview": true
        }
      }
    

    Then the output is html with iframe already locating the office online.



  • @jan_blaha , thanks, works for me.


Log in to reply
 

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