'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.Collections.GenericImportsSystem.GlobalizationImportsSystem.XmlImportsGrapeCity.Documents.Word '' This example shows how to format data from different data sources'' in a culture-aware way by associating the correct culture with'' each data source.PublicClassDataTplCultureOutFunctionCreateDocx() AsGcWordDocument'' USD to EUR conversion rate:Dim usd2eur AsDecimalIfExchangeOperations.ExchangeRateToEuro.TryGetValue("USD", usd2eur) Then'' Define the 'dsEn' data source to contain random amounts in US dollars:Dim dsEn = NewList(OfDecimal)Dim rnd = Util.NewRandom()Dim i = 0DoWhile i < rnd.Next(5, 15) dsEn.Add(CDec(rnd.Next(10, 1000) / 10F)) i += 1Loop '' The 'dsFr' data source will contain same amounts converted to EUR:Dim dsFr = NewList(OfDecimal)ForEach d In dsEn dsFr.Add(d / usd2eur)Next '' Create Word documentDim doc = NewGcWordDocument() '' Add the two data sources, associating a proper culture with each data source: doc.DataTemplate.DataSources.Add("dsEn", dsEn, CultureInfo.GetCultureInfo("en-US")) doc.DataTemplate.DataSources.Add("dsFr", dsFr, CultureInfo.GetCultureInfo("fr-FR")) '' The template will print two columns of data, the amounts from 'dsEn' in the first column,'' the corresponding amounts from 'dsFr' in the second one. Because we specified correct'' cultures for the two data sources, the culture-aware currency format will format'' the data appropriately: doc.Body.Paragraphs.Add("{{#dsEn}:seq(x)}{{#dsFr}:follow(x)}{{dsEn.value}:format(C)} is approximately {{dsFr.value}:format(C)}{{/dsFr}}{{/dsEn}}") '' Process the template: doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US")) '' Done:Return docElseDim doc = NewGcWordDocument() doc.Body.Paragraphs.Add("Could not get exchange rates from www.ecb.int, please try again later.", doc.Styles(BuiltInStyleId.Heading1))Return docEndIfEndFunction '' From https://docs.microsoft.com/en-us/answers/questions/785478/api-for-currency-exchange-rate.html:FriendClassExchangeOperationsPublicSharedReadOnlyExchangeRateToEuroAsNewDictionary(OfString, Decimal)PublicSharedFromCurrencyAsNewList(OfString)PublicSharedToCurrencyAsNewList(OfString) SharedSubNew()LoadRates()EndSub PublicSharedSubLoadRates()TryDim xmlDoc AsNewXmlDocument() xmlDoc.Load("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml") ForEach node AsXmlNodeIn xmlDoc.DocumentElement.ChildNodes(2).ChildNodes(0).ChildNodesExchangeRateToEuro.Add(node.Attributes("currency").Value, Decimal.Parse(node.Attributes("rate").Value))FromCurrency.Add(node.Attributes("currency").Value)ToCurrency.Add(node.Attributes("currency").Value)NextCatch'' Eat errors, ExchangeRateToEuro will stay empty.EndTryEndSubEndClassEndClass