DataTplCultureIn.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.Globalization
Imports GrapeCity.Documents.Word

'' This example shows how text input data that is stored in different data
'' sources that are formatted for different cultures (in this example,
'' floating point values are stored with points and commas as decimal
'' separators) can be correctly processed by DsWord's report templates
'' if the correct culture is specified for each data source.
Public Class DataTplCultureIn
    Function CreateDocx() As GcWordDocument
        '' Strings with floating-point data using point as the decimal separator:
        Dim dsUs = {"1.234", "56.78", "987.65", "3.14"}
        '' Same data using comma as the decimal separator:
        Dim dsFr = {"1,234", "56,78", "987,65", "3,14"}

        Dim doc = New GcWordDocument()
        doc.Body.Paragraphs.Add(
            "The two columns of data below come from two different data sources, " +
            "with different cultures specified for each data source. " +
            "Numbers in the left column were converted from strings with point as the decimal separator, " +
            "with ""en-US"" culture specified for the data source. " +
            "Numbers in the right column were converted from strings with comma as the decimal separator, " +
            "with ""fr-FR"" culture specified for the data source. " +
            "Both sets of data were converted correctly using the ""todouble()"" formatter.")
        doc.Body.Paragraphs.Add("{{#dsUs}:seq(x)}{{#dsFr}:follow(x)}{{dsUs.value}:todouble()} == {{dsFr.value}:todouble()}{{/dsFr}}{{/dsUs}}")
        doc.DataTemplate.DataSources.Add("dsUs", dsUs, CultureInfo.GetCultureInfo("en-US"))
        doc.DataTemplate.DataSources.Add("dsFr", dsFr, CultureInfo.GetCultureInfo("fr-FR"))

        '' Generate the document by template processing
        doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US"))

        '' Done:
        Return doc
    End Function
End Class