'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.GlobalizationImportsGrapeCity.Documents.Word '' This sample demonstrates the use of BatchStepProcessor class,'' which allows you to execute a single step of batch processing,'' processing a single specified record of the data source.'''' See also the DataTplBatchOceans sample, which uses the same data source'' but processes all data items in a batch.'' NOTE: the C# original (DataTplBatchStep.cs) has a typo in its SampleId'' attribute value - "DataTplBatchSte" instead of "DataTplBatchStep". Preserved'' here verbatim so this VB sample resolves correctly against that existing C# sample.PublicClassDataTplBatchStepFunctionCreateDocx() 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"}}} } '' Create and load the template DOCX:Dim doc = NewGcWordDocument() doc.Load(Path.Combine("Resources", "WordDocs", "BatchOceansTemplate.docx")) '' Add the data source to the data template data sources doc.DataTemplate.DataSources.Add("ds", oceans) '' Initialize the batch step processor:Dim batchProcessor = doc.DataTemplate.InitBatchStepProcessor(CultureInfo.GetCultureInfo("en-US")) '' Get a random record index to process:Dim recordIndex = Random.Shared.Next(0, batchProcessor.MaxRecordIndex) '' Process the specific record index only.'' Note that we must save the document using the action passed to ProcessRecord(),'' as the original document reverts to its initial state after processing:Dim ms = NewMemoryStream() batchProcessor.ProcessRecord(recordIndex, Sub() doc.Save(ms)) '' Load the processed document from the memory stream and return it: ms.Position = 0 doc.Load(ms) doc.Body.Paragraphs.Insert($"Note: This document was generated by processing record index {recordIndex} only.", doc.Styles(BuiltInStyleId.BlockText), InsertLocation.Start) Return docEndFunctionEndClass