'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DataImportsSystem.LinqImportsSystem.GlobalizationImportsGrapeCity.Documents.Word '' The code in this example loads a DOCX document (created in MS Word)'' containing a report template, and depending on the selected demo,'' either adds a data source and generates the data bound report,'' or simply returns the unmodified template for reference.PublicClassDataTplUseCasesPublicFunctionCreateDocx(ByRef sampleParams AsString()) AsGcWordDocumentDim doc = NewGcWordDocument() '' Load the template DOCX doc.Load(Path.Combine("Resources", "WordDocs", sampleParams(3))) Using ds = NewDataSet()'' Load the data set: ds.ReadXml(Path.Combine("Resources", "data", "DsWordTplDataSet.xml")) '' Return the unmodified template document for referenceIf sampleParams.Length >= 6AndAlso sampleParams(5) = "template"ThenReturn docEndIf '' Add the data source to the data template data sourcesIf sampleParams.Length >= 5AndAlsoNotString.IsNullOrEmpty(sampleParams(4)) Then doc.DataTemplate.DataSources.Add("ds", ds.Tables(sampleParams(4)))Else doc.DataTemplate.DataSources.Add("ds", ds)EndIf '' The document already has all the necessary bindings,'' so we only need to process the data template: doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US"))EndUsing '' DoneReturn docEndFunction PublicFunctionCreateDocx(Optional parsIdx AsInteger = 0) AsGcWordDocumentReturnCreateDocx(GetSampleParamsList()(parsIdx))EndFunction PublicSharedFunctionGetSampleParamsList() As List(OfString())'' Mandatory: name, description, info'' Custom: template DOCX [[, table] , "template"]ReturnNew List(OfString()) From {NewString() {"@use-data-tpl/Lease Agreement", "Generate a lease agreement", Nothing,"Lease_Agreement_Template.docx", "LeaseAgreement"},NewString() {"@use-data-tpl/Consulting Agreement", "Generate a consultancy agreement", Nothing,"Consulting_Agreement_Template.docx", "ConsAgreement"},NewString() {"@use-data-tpl/Rental Agreement", "Generate a house rental agreement", Nothing,"House_Rental_Template.docx", "HouseRentalAgreement"},NewString() {"@use-data-tpl/Employment Contract", "Generate an employment contract", Nothing,"Employment_Contract_Template.docx", "EmploymentContract"},NewString() {"@use-data-tpl-src/Lease Agreement", "Template Lease_Agreement_Template.docx", Nothing,"Lease_Agreement_Template.docx", Nothing, "template"},NewString() {"@use-data-tpl-src/Consulting Agreement", "Template Consulting_Agreement_Template.docx", Nothing,"Consulting_Agreement_Template.docx", Nothing, "template"},NewString() {"@use-data-tpl-src/Rental Agreement", "Template House_Rental_Template.docx", Nothing,"House_Rental_Template.docx", Nothing, "template"},NewString() {"@use-data-tpl-src/Employment Contract", "Template Employment_Contract_Template.docx", Nothing,"Employment_Contract_Template.docx", Nothing, "template"},NewString() {"@use-data-tpl-src/Order Invoice", "Template InvoiceTemplate.docx", Nothing,"InvoiceTemplate.docx", Nothing, "template"},NewString() {"@use-data-tpl-src/Closing Disclosure", "Template Closing_Disclosure_Template.docx", Nothing,"Closing_Disclosure_Template.docx", Nothing, "template"},NewString() {"@use-data-tpl-src/Vacation Itinerary", "Template Vacation_Itinerary_Template.docx", Nothing,"Vacation_Itinerary_Template.docx", Nothing, "template"} }EndFunctionEndClass