Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

Gets or sets the culture information to be used to convert the numeric strings such as currencies and formatted numerals in the imported data to numbers. By default it is set to System.Globalization.CultureInfo.InvariantCulture

...

.

...

This

...

property

...

setting

...

will

...

take

...

effect

...

only

...

if

...

the

...

ConvertStrings

...

property

...

is

...

set

...

to

...

true

...

.

Signature
C#
C#
public System.Globalization.CultureInfo ConversionCulture { get; set; } 
{signature}
{signature:
}
Signature
vb.net
vb.net
Public Property ConversionCulture() As System.Globalization.CultureInfo
{signature}

{exceptions}
{exception:ArgumentException}
When the {{ConversionCulture}} property is set to {{null}} \(C\#\) or {{Nothing}} \
Exceptions
Exception
ArgumentException
ArgumentException

When the ConversionCulture property is set to null (C#) or Nothing (VB.NET

\

),

ExcelWriter

will

throw

this

exception.

{exception} {remarks} By

Remarks

By default,

when

importing

data,

ExcelWriter

will

not

convert

numeric

strings

to

numbers.

If

the

[

ConvertStrings

|DataImportProperties.ConvertStrings]

property

is

set

to

{{

true

}}

,

ExcelWriter

will

parse

the

strings

into

a

{{

decimal

}}

type

by

using

the

culture

information

specified

through

the

{{

ConversionCulture

}}

property.

However

if

{{

ConvertStrings

}}

is

set

to

{{

false

}}

,

the

setting

of

the

{{

ConversionCulture

}}

property

will

not

take

any

effect

and

the

numeric

string

will

not

be

converted.

If {{ConvertStrings}} is enabled but no culture is set for the {{ConversionCulture}} property, then ExcelWriter will use the invariant culture, {{

If ConvertStrings is enabled but no culture is set for the ConversionCulture property, then ExcelWriter will use the invariant culture, System.Globalization.CultureInfo.InvariantCulture

}}

,

to

parse

the

numeric

strings.

{remarks} {example} {code:csharp|title=C#}

Example
Code Block
csharp
csharp
titleC#

      DataImportProperties importProps = wb.CreateDataImportProperties();

      //--- Get ConversionCulture
      System.Globalization.CultureInfo conversionCulture = importProps.ConversionCulture;

      //--- In order for the ConversionCulture setting to take effect, ConvertStrings has to be enabled first 
      importProps.ConvertStrings = true;

      //--- Example 1: Set ConversionCulture to the current thread's culture
      importProps.ConversionCulture = System.Threading.Thread.CurrentThread.CurrentCulture;

      //--- Example 2: Set ConversionCulture specifically to the "en-US" culture 
      importProps.ConversionCulture = new System.Globalization.CultureInfo("en-US");
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}

     Dim importProps As DataImportProperties = wb.CreateDataImportProperties()

     '--- Get ConversionCulture
     Dim conversionCulture As System.Globalization.CultureInfo =  importProps.ConversionCulture

     '--- In order for the ConversionCulture setting to take effect, ConvertStrings has to be enabled first 
     importProps.ConvertStrings = True 

     '--- Example 1: Set ConversionCulture to the current thread's culture
     importProps.ConversionCulture = System.Threading.Thread.CurrentThread.CurrentCulture

     '--- Example 2: Set ConversionCulture specifically to the "en-US" culture
     importProps.ConversionCulture = New System.Globalization.CultureInfo("en-US")   

{code} {example}