Mostly a newb...



  • OK, I have several reports mostly working, but the subtotals are not -- just blank except for the "subtotal" label.
    My totals are fine (computed in javascript). Using 2.4.0 (no choice, no upgrade until next year), javascript calling mongo db for data, template using handlebars, html, so nothing too fancy.

    in general, template is like this for table section:

    <tbody>
        {{#each reportData}}
        <tr>
            <td>{{TopGroup}}</td>
            {{#each GroupData}}
            {{#unless @first}}
            <td>{{#ExcelType}}{{../TopGroup}}{{/ExcelType}}</td>
            {{/unless}}
            <td>{{Type}}</td>
            <td>{{SubType}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Quantity}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Price}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{NormalTotal}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Discount}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Total}}</td>
        </tr>
        {{/each}}
        {{#ExcelNot}}
        <tr class="subtotal">
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Subtotal</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Quantity}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Price}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{NormalTotal}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Discount}}</td>
            <td data-cell-type="number" data-cell-format-str="0">{{Total}}</td>
        </tr>
        <tr>
            <td colspan=18>&nbsp;</td>
        </tr>
        {{/ExcelNot}}
        {{/each}}
    

    Data is something like:

    [{
    "TopGroup": "Fred", 
    "GroupData": [{
    	"TopGroup": "Fred", 
    	"Type": "Existing", 
    	"SubType": "Promo12", 
    	"Quantity": 10,
    	"Price":    15.2,
    	"NormalTotal": 152.0
    	"Discount": -23.0
    	"Total": 129.0
    	}, 
    	{
    	"TopGroup": "Fred", 
    	"Type": "Existing", 
    	"SubType": "NA", 
    	"Quantity": 10,
    	"Price":    15.2,
    	"NormalTotal": 152.0
    	"Discount": 0
    	"Total": 152.0
    	}]
    }]
    

    Notes: Made up names and data, not matching real report (except in layout). Could be typos, I hope not...



  • Likely a problem with the ExcelNot helper...
    Could you please share the demo in the playground so I can take a look?
    https://playground.jsreport.net/



  • I don't think so, I remove the #ExcelNot and /ExcelNot and no difference. ExcelNot is simply toggling options based on html or not output.

     function ExcelNot(opts) {
        if (ReportType == 'html-to-xlsx') {
          return opts.inverse(this);
        } else {
          return opts.fn(this);
        }
    }
    

    This helper is working on other reports. I've compared this report to other reports, and they look the same, but obviously I'm doing something wrong...



  • And is there a reference for jsreport? The "learn" is rather disjointed and attempts to be all for all types but makes understanding the features of templates incomprehensible.



  • I don't think so, I remove the #ExcelNot and /ExcelNot and no difference. ExcelNot is simply toggling options based on html or not output.

    I see.... I would really need that playground demo to be able to check where is the problem.

    You can learn more about handlebars in dedicated docs here
    https://handlebarsjs.com/guide/


Log in to reply
 

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