'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.Collections.GenericImportsSystem.GlobalizationImportsGrapeCity.Documents.Word '' This sample shows how arrays of primitive value types (such as int() or List(Of String))'' can be used as data sources for templates, injecting the array elements into'' the document with the "value" template tag.'' Types that allow using the "value" tag are those for which Type.IsPrimitive gets true'' (except pointer types), and strings.PublicClassDataTplElemCollFunctionCreateDocx() AsGcWordDocumentDim doc = NewGcWordDocument() '' Add a few simple arrays as data sources: doc.DataTemplate.DataSources.Add("dsInts", NewInteger() {1, 2, 3, 4, 5, 6, 7, 8, 9}) doc.DataTemplate.DataSources.Add("dsConsts", NewDouble() {Math.PI, Math.E}) doc.DataTemplate.DataSources.Add("dsStrs", NewList(OfString) From {"Pacific", "Atlantic", "Indian", "Southern", "Arctic"}) '' Add a list template so that the data is formatted as a list:Dim myListTemplate = doc.ListTemplates.Add(BuiltInListTemplateId.BulletDefault, "myListTemplate") '' Integers: doc.Body.Paragraphs.Add("Integers from 1 to 9:", doc.Styles(BuiltInStyleId.Heading1))Dim p = doc.Body.Paragraphs.Add("{{#dsInts}}{{dsInts.value}}{{/dsInts}}", doc.Styles(BuiltInStyleId.ListParagraph)) p.ListFormat.Template = myListTemplate '' Math constants: doc.Body.Paragraphs.Add("Constants from the Math class:", doc.Styles(BuiltInStyleId.Heading1)) p = doc.Body.Paragraphs.Add("{{#dsConsts}}{{dsConsts.value}}{{/dsConsts}}", doc.Styles(BuiltInStyleId.ListParagraph)) p.ListFormat.Template = myListTemplate '' Strings (oceans): doc.Body.Paragraphs.Add("Strings (oceans):", doc.Styles(BuiltInStyleId.Heading1)) p = doc.Body.Paragraphs.Add("{{#dsStrs}}{{dsStrs.value}:toupper()}{{/dsStrs}}", doc.Styles(BuiltInStyleId.ListParagraph)) p.ListFormat.Template = myListTemplate '' Expand all data templates in the document: doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US")) '' Done:Return docEndFunctionEndClass