Wiki Markup |
---|
{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|DataImportProperties.ConvertStrings] property is set to {{true}}. {excerpt} {signature:C#} public System.Globalization.CultureInfo ConversionCulture { get; set; } {signature} {signature:vb.net} Public Property ConversionCulture() As System.Globalization.CultureInfo {signature} {exceptions} {exception:ArgumentException} When the {{ConversionCulture}} property is set to {{null}} \(C\#\) or {{Nothing}} \(VB.NET\), ExcelWriter will throw this exception. {exception} {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, {{System.Globalization.CultureInfo.InvariantCulture}}, to parse the numeric strings. {remarks} {example} {code:csharp|title=C#} 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:vb.net|title=vb.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} |
Page History
Overview
Content Tools