Calculation functions calculate inner expression and write result as output. Currently, a function subset of our Calc engine has been adapted to use with the template engine and hence the feature supports various binary, unary and arithmetic operators, aggregate functions, and text functions. The examples below show how to use aggregate and arithmetic operations to create expressions in Calc function.
C# |
Copy Code |
---|---|
var doc = new GcWordDocument(); doc.DataTemplate.DataSources.Add("a", new int[] { 1, 2, -2, 16, 7, 5, 4 }); // aggregate function doc.Body.Paragraphs.Add("Aggregate function results:", doc.Styles[BuiltInStyleId.Heading2]); var p = doc.Body.Paragraphs.Add("{{ calc Sum(a.value) }}"); // arithmetic function doc.Body.Paragraphs.Add("Arithmetic function results:", doc.Styles[BuiltInStyleId.Heading2]); doc.Body.Paragraphs.Add("{{calc a.value * 2 + 12 }}"); doc.DataTemplate.Process(); doc.Save("Calculation.docx"); |
To view Calc functions in action, see Calculation demo sample.
Limitations