How to use jsrender engine for xlsx recipe with client application & webapi and jsreport embedded server.



  • I was trying to render xlsx jsreport on client application with jsrender engine. But i was getting "Syntax error Unmatched or missing tag: {{/xlsxAdd}} in template:" error with the following template.

    {{xlsxRemove "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row" 1}}
    
    {{#each people}}
    {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
    <row>
        <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{name}}</t></is></c>
        <c t="inlineStr" s="{{@root.$removedItem.c.[1].$.s}}"><is><t>{{gender}}</t></is></c>
        <c s="{{@root.$removedItem.c.[2].$.s}}"><v>{{age}}</v></c>
    </row>
    {{/xlsxAdd}}
    {{/each}}
    
    {{{xlsxPrint}}}
    

    Early response appreciated.


  • administrators

    @Kambhammettu the error is because you are using handlebars template syntax inside a jsrender template.

    try to convert the template from handlebars syntax to the equivalence in jsrender syntax, more info of syntax here https://jsreport.net/learn/jsrender or in jsrender website. most examples of xlsx are in handlebars syntax so i would recommend to use handlebars if possible, just to avoid having a bad time



  • I changed template engine from jsrender to handlebars. It says "Error occured - Error during rendering report: Missing helper: 'xlsxRemove'".
    I prepared my webapi response like the following,

     var result = HttpUtility.JavaScriptStringEncode(JsonConvert.SerializeObject(new
                {
                    content = File.ReadAllText("//somepath..\jsexample\Examples\excelSample.html"),
                    recipe = "xlsx",             
                    data = new { dataJson = File.ReadAllText("//somepath..\jsexample\Examples\data.json") },            
                    engine = "handlebars"
                }));
    

    Thanks for your valuable help in advance.



  • Maybe not the problem, but your request body seems to be wrong.
    It should be

    {
      "template": { "content": "foo", "engine": "handlebars", "recipe": "xlsx" },
      "data": { "foo": "hello" }
    }
    

    https://jsreport.net/learn/api



  • I am just serializing my data as mentioned above and sending as response to client. It works for me with phantom-pdf recipe. The rendering would start from client application.



  • May I know, Why it is throwing error in missing helper "xlsxRemove" for the following content.

    {{xlsxRemove "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row" 1}}

    {{#each people}}
    {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
    <row>
    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{name}}</t></is></c>
    <c t="inlineStr" s="{{@root.$removedItem.c.[1].$.s}}"><is><t>{{gender}}</t></is></c>
    <c s="{{@root.$removedItem.c.[2].$.s}}"><v>{{age}}</v></c>
    </row>
    {{/xlsxAdd}}
    {{/each}}

    {{{xlsxPrint}}}

    I am running my embedded server with .Net Framework using jsreport.Embedded dll.
    Early response appreciated.



  • This should work and it has likely nothing to do with the content. It works for me.
    Such error could pop up if the recipe is not correctly resolved.

    Do you see entry like this in the jsreport output or log
    Rendering anonymous template { recipe:xlsx,engine:handlebars}



  • No, I didn't see such type of message.



  • Can you post the output log?



  • Error occured - Error during rendering report: Missing helper: 'xlsxRemove'
    Stack - Error: Missing helper: 'xlsxRemove'
    at new Error (<anonymous>)
    at Error.Exception (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\exception.js:13:41)
    at Object.<anonymous> (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\base.js:66:13)
    at Object.eval (eval at <anonymous> (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js:171:23), <anonymous>:2:221)
    at ret (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\runtime.js:137:30)
    at ret (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js:422:21)
    at module.exports (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\render\handlebarsEngine.js:20:12)
    at evalmachine.<anonymous>:1:9
    at module.exports (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\render\renderExecution.js:113:8)
    at D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\tasks\workersCluster.js:134:49
    From previous event:
    at Reporter.renderContent (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:183:38)
    at Object.reporter.extensionsManager.recipes.push.execute (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\extension\xlsx\lib\xlsx.js:72:29)
    at Reporter.executeRecipe (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:165:19)
    at dataProvider.startContext.then.then.then.then.then.then.fail.e.message (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:136:21)



  • This is actually just error. You should find in jsreport logs whats happening before.



  • It could be somewhere here D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\logs.



  • There are two files error.log and reporter.log. Which one i need to post?



  • The content of reporter.log.



  • This post is deleted!


  • This post is deleted!


  • We just need relevant part, probably at the end, few lines before the last error



  • Okay. Sorry for the inconvenience.

    2017-05-10T14:19:13.200Z - warn: Error when processing render request Error during rendering report: Missing helper: 'xlsxRemove' Error: Missing helper: 'xlsxRemove'
    at new Error (<anonymous>)
    at Error.Exception (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\exception.js:13:41)
    at Object.<anonymous> (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\base.js:66:13)
    at Object.eval (eval at <anonymous> (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js:171:23), <anonymous>:2:221)
    at ret (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\runtime.js:137:30)
    at ret (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js:422:21)
    at module.exports (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\render\handlebarsEngine.js:20:12)
    at evalmachine.<anonymous>:1:9
    at module.exports (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\render\renderExecution.js:113:8)
    at D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\tasks\workersCluster.js:134:49
    From previous event:
    at Reporter.renderContent (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:183:38)
    at Object.reporter.extensionsManager.recipes.push.execute (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\extension\xlsx\lib\xlsx.js:72:29)
    at Reporter.executeRecipe (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:165:19)
    at dataProvider.startContext.then.then.then.then.then.then.fail.e.message (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:136:21)
    2017-05-10T14:19:13.200Z - warn: Error during processing request: http://192.168.2.69/api/report?studio=embed&serverUrl=http%3A%2F%2F192.168.2.69%2Fjsreport.axd%3Furl%3D%2F details: Error during rendering report: Missing helper: 'xlsxRemove' Error: Missing helper: 'xlsxRemove'
    at new Error (<anonymous>)
    at Error.Exception (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\exception.js:13:41)
    at Object.<anonymous> (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\base.js:66:13)
    at Object.eval (eval at <anonymous> (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js:171:23), <anonymous>:2:221)
    at ret (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\runtime.js:137:30)
    at ret (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js:422:21)
    at module.exports (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\render\handlebarsEngine.js:20:12)
    at evalmachine.<anonymous>:1:9
    at module.exports (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\render\renderExecution.js:113:8)
    at D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\tasks\workersCluster.js:134:49
    From previous event:
    at Reporter.renderContent (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:183:38)
    at Object.reporter.extensionsManager.recipes.push.execute (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\extension\xlsx\lib\xlsx.js:72:29)
    at Reporter.executeRecipe (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:165:19)
    at dataProvider.startContext.then.then.then.then.then.then.fail.e.message (D:\Practice\jsexample\jsexample\App_Data\jsreport-net-embedded\lib\reporter.js:136:21)



  • Hey jan_blaha, Anything found from your side? I am eagerly waiting for the solution. Your suggestions are more helpful to me. Thank you for your valuable suggestions.



  • This still the exception, not the important logs which are BEFORE :)

    However I found out from the stack trace that you use very very old jsreport.embedded nuget package which doesn't have support for this advanced xlsx manipulations. You can see what will work with your current jsreport version here - https://playground.jsreport.net/studio/workspace/YBjmBsPFa/1

    I would recommend you to run standalone jsreport instance as separate server and communicate with it from your c# solution. Perhaps using jsreport.Client nuget.


Log in to reply
 

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