//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.Globalization;usingGrapeCity.Documents.Word; namespaceDsWordWeb.Demos{// This example demonstrates the available logical functions// that can be used with the 'calc' report templates feature.publicclassDataTplCalcLogical {publicGcWordDocumentCreateDocx() {// A simple data source to be used by the logical functions:var data = newbool[] { true }; var doc = newGcWordDocument(); // Add the data source: doc.DataTemplate.DataSources.Add("ds", data); // Styles and templates to show results:var bulletListTemplate = doc.ListTemplates.Add(BuiltInListTemplateId.BulletDefault, "bulletListTemplate");var exStyle = doc.Styles[BuiltInStyleId.Heading3];var resStyle = doc.Styles[BuiltInStyleId.Strong]; var paras = doc.Body.Paragraphs;add("{{ calc Iif(ds.value, \"Iif result true\", \"Iif result false\") }}");add("{{ calc IsNull(\"Some data\") }}");add("{{ calc Not IsNull(\"Some data\") }}"); // Process the templates: doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US")); // Add a short note describing the demo at the top of the document: paras.Insert("This example demonstrates the available logical functions " +"that can be used with the 'calc' report templates feature. " +"Please see this example's source code for full details.",InsertLocation.Start); paras.Insert("Report templates: available calc logical functions", doc.Styles[BuiltInStyleId.Heading1], InsertLocation.Start); // Done:return doc; voidadd(string expr) {// \x200B is a zero-width space used to prevent template expansion: paras.Add(expr.Insert(1, "\x200B") + " : ", exStyle).ListFormat.Template = bulletListTemplate; paras.Last.GetRange().Runs.Add(expr, resStyle); } } }}