'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.LinqImportsSystem.GlobalizationImportsGrapeCity.Documents.Word '' This sample uses data templates to print a simple list of items'' from a hierarchical data source, uppercasing each item.PublicClassDataTplSimpleListFunctionCreateDocx() AsGcWordDocument'' The data source (ocean And sea data from Wikipedia):Dim oceans = {NewWith {.name = "Pacific", .areaOfWorldOcean = 0.466, .volumeOfWorldOcean = 0.501, .seas = {NewWith {.name = "Australasian Mediterranean Sea"}, NewWith {.name = "Philippine Sea"}, NewWith {.name = "Coral Sea"}, NewWith {.name = "South China Sea"}}},NewWith {.name = "Atlantic", .areaOfWorldOcean = 0.235, .volumeOfWorldOcean = 0.233, .seas = {NewWith {.name = "Sargasso Sea"}, NewWith {.name = "Caribbean Sea"}, NewWith {.name = "Mediterranean Sea"}, NewWith {.name = "Gulf of Guinea"}}},NewWith {.name = "Indian", .areaOfWorldOcean = 0.195, .volumeOfWorldOcean = 0.198, .seas = {NewWith {.name = "Arabian Sea"}, NewWith {.name = "Bay of Bengal"}, NewWith {.name = "Andaman Sea"}, NewWith {.name = "Laccadive Sea"}}},NewWith {.name = "Southern", .areaOfWorldOcean = 0.061, .volumeOfWorldOcean = 0.054, .seas = {NewWith {.name = "Weddell Sea"}, NewWith {.name = "Somov Sea"}, NewWith {.name = "Riiser-Larsen Sea"}, NewWith {.name = "Lazarev Sea"}}},NewWith {.name = "Arctic", .areaOfWorldOcean = 0.043, .volumeOfWorldOcean = 0.014, .seas = {NewWith {.name = "Barents Sea"}, NewWith {.name = "Greenland Sea"}, NewWith {.name = "East Siberian Sea"}, NewWith {.name = "Kara Sea"}}} } Dim doc = NewGcWordDocument() '' Add the data source to the data template data sources'' (note that in this release, only one data source can be added): doc.DataTemplate.DataSources.Add("ds", oceans) '' Add a list template so that the data Is formatted as a list:Dim myListTemplate = doc.ListTemplates.Add(BuiltInListTemplateId.BulletDefault, "myListTemplate") '' The single paragraph added to the document contains template tags'' - {{#ds}}..{{/ds}} -- root template, 'ds' is the name of the data source'' - {ds.seas.name} -- fetches the sea name'' - :toupper() -- uppercases the data:Dim p = doc.Body.Paragraphs.Add("{{#ds}}{{ds.seas.name}:toupper()}{{/ds}}", doc.Styles(BuiltInStyleId.ListParagraph)) p.ListFormat.Template = myListTemplate '' This call expands all data templates in the document,'' replacing template tags with data (iterating over all data items): doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US")) '' DoneReturn docEndFunctionEndClass