TextFileDecimalSeparator 属性 (Excel)QueryTable.TextFileDecimalSeparator property (Excel)

返回或设置小数分隔符,在将文本文件导入查询表中时,Microsoft Excel 将使用小数分隔符。Returns or sets the decimal separator character that Microsoft Excel uses when you import a text file into a query table. 默认值为系统小数分隔符。The default is the system decimal separator character. 读/写 StringRead/write String.

语法Syntax

表达式TextFileDecimalSeparatorexpression.TextFileDecimalSeparator

_表达式_一个代表查询表对象**** 的变量。expression A variable that represents a QueryTable object.

注解Remarks

仅当查询表基于文本文件中的数据 (将**QueryType** 属性设置为xlTextImport) 时, 才使用此属性, 当文件包含的小数和千位分隔符与计算机上使用的这些分隔符不同, 因为使用不同的语言设置。Use this property only when your query table is based on data from a text file (with the QueryType property set to xlTextImport) when the file contains decimal and thousands separators that are different from those used on the computer due to a different language setting being used.

下表显示了使用各种分隔符将文本导入 Microsoft Excel 时的结果。The following table shows the results when you import text into Microsoft Excel by using various separators. 数字结果显示在最右边的列中。Numeric results are displayed in the rightmost column.

系统小数分隔符System decimal separator 系统千位分隔符System thousands separator TextFileDecimalSeparator 值TextFileDecimalSeparator value TextFileThousandsSeparator 值TextFileThousandsSeparator value 导入的文本Text imported 单元格的值(数据类型)Cell value (data type)
PeriodPeriod 逗号Comma 逗号Comma PeriodPeriod 123.123,45123.123,45 123,123.45(数字)123,123.45 (numeric)
PeriodPeriod 逗号Comma 逗号Comma 逗号Comma 123.123,45123.123,45 123.123,45(文本)123.123,45 (text)
逗号Comma PeriodPeriod 逗号Comma PeriodPeriod 123,123.45123,123.45 123,123.45(数字)123,123.45 (numeric)
PeriodPeriod 逗号Comma PeriodPeriod 逗号Comma 123 123.45123 123.45 123 123.45(文本)123 123.45 (text)
句号Period 逗号Comma 句号Period 空格Space 123 123.45123 123.45 123,123.45(数字)123,123.45 (numeric)

如果使用用户界面导入数据, 则会将来自 web 查询或文本查询的数据作为一个查询表**** 对象导入, 而将所有其他外部数据作为**ListObject** 对象导入。If you import data by using the user interface, data from a web query or a text query is imported as a QueryTable object, while all other external data is imported as a ListObject object.

如果使用对象模型导入数据, 则必须将来自 web 查询或文本查询的数据作为查询表导入****, 而所有其他外部数据均可作为ListObject或查询表导入。 ****If you import data by using the object model, data from a web query or a text query must be imported as a QueryTable, while all other external data can be imported as either a ListObject or a QueryTable.

TextFileDecimalSeparator 属性仅适用于 QueryTable 对象。The TextFileDecimalSeparator property applies only to QueryTable objects.

示例Example

本示例保存原始小数分隔符并将其设置为工作表 Sheet1 中第一个查询表的逗号, 以便在 Microsoft Excel 的美国英语版本中导入法语文本文件 (例如)。This example saves the original decimal separator and sets it to a comma for the first query table on Sheet1 in preparation for importing a French text file (for example) into the U.S. English version of Microsoft Excel.

strDecSep = Worksheets("Sheet1").QueryTables(1) _ 
 .TextFileDecimalSeparator 
Worksheets("Sheet1").QueryTables(1) _ 
 .TextFileDecimalSeparator = ","

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.