Adding calculation expression in docx template
-
Yes. In case your template is not stored inside jsreport template store you need to pass helpers in
Template.Helpers = "function itemTotal(price, qty) { return price * qty } function total() { return this.data.reduce((p, c) => p + (c.price * c.qty), 0) }"
-
That's very helpful.
Does the .NET nuget package has docx recipe yet? or it's still being developed?
-
The local binary doesn't have it yet. Soon the 2.6.0 should have it.
-
That's great to know. Looking forward to it. Thanks a lot for the help.
-
I am trying to call the Docx engine through .net nuget package jsreport.Local --> jsreport.Client --> jsreport.Types. Since Docx recipe is not thr in enum I am not able to create Docx through code.
Can you let me know when can we expect Docx recipe type in jsreport.client?
-
You don't need strong types. Just send an anonymous object using this interface method. The missing type shouldn't be a limitation for you.
However, we will add types soon in the next days.
-
Thanks for your quick response. I tried to call the RenderAsync with Anonymous object but I am getting error related to recipe. Below is excerpts from my code.
private static void GenerateWord(ReportingService rs)
{
var html = System.IO.File.ReadAllText(@"C:\temp\CV.htm");var prop = new JProperty( "name", "Test Name"); var customReport = rs.RenderAsync(new { Data = new JObject { prop } , Template = new {Content = html, Engine = Engine.Handlebars } } ); using (var fs = File.Create(@"C:\temp\CV_converted.docx")) { customReport.Result.Content.CopyTo(fs); } }
Above code gives Engine exception:
Unable to render template. Engine '0' not found. If this is a custom engine make sure it's properly installed from npmKindly share your thoughts. What should be the structure of anonymous object?
-
@meetvishalt There is now API section in the docx recipe documentation https://jsreport.net/learn/docx#api
-
@jan_blaha I tried passing the helper function as you suggested but I am getting an error. I have passed the function in json object as
"helpers" : "function itemTotal(price, qty) {
return price * qty
}function total() {
return this.data.reduce((p, c) => p + (c.price * c.qty), 0)
}"
-
@amitmishra3 What error....?