Đổi văn bản thành số

Defaults settings in Calc converts text inside cells to the respective numeric values if an unambiguous conversion is possible. If no conversion is possible, Calc returns a #VALUE! error.

Only integer numbers including exponent are converted, and ISO 8601 dates and times in their extended formats with separators. Anything else, like fractional numbers with decimal separators or dates other than ISO 8601, is not converted, as the text string would be locale dependent. Leading and trailing blanks are ignored.

Các định dạng ISO 8601 sau đây được chuyển đổi:

Mã thế kỉ CC có thể được bỏ trống. Thay cho dấu phân cách ngày và giờ, phải dùng chính xác chỉ một kí tự dấu cách.

Nếu ngày tháng được cho, nó phải là một ngày lịch Gregorian hợp lệ. Trong trường hợp này thời gian phải nằm trong khoảng 00:00 tới 23:59:59.99999...

Nếu cho chỉ một chuỗi thời gian, có thể sẽ có một giá trị giờ lớn hơn 24, trong khi phút và giây có giá trị cực đại là 59.

note

The conversion is done for single scalar values only, not within ranges.


The conversion is done for single scalar values, as in =A1+A2, or ="1E2"+1. Cell range arguments are not affected, so SUM(A1:A2) differs from A1+A2 if at least one of the two cells contain a convertible string.

Các chuối trong côg thức cũng sẽ được chuyển đổi, chẳng hạn ="1999-11-22"+42, sẽ trả về ngày tháng là 42 ngày sau ngày 22 tháng 11 năm 1999. Việc tính toán các ngày tháng liên quan tới bản địa hóa có dạng các chuỗi trong công thức sẽ trả về sai số. Ví dụ, các chuỗi ngày tháng bản địa hóa "11/22/1999" hay "22.11.1999" không thể dùng cho chuyển đổi tự động.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Thí dụ

In A1 enter the text '1e2 (which is converted to the number 100 internally).

In A2 enter =A1+1 (which correctly results in 101).

The formula =SUM(A1:A2), returns 101 instead of 201 because the conversion does not occur in a range, only for single scalar values. Here, '1e2 is treated as string which has value 0 for the SUM function.

=SUM("1E2";1) returns #VALUE! because SUM() and some others that iterate over number sequences explicitly check the argument type.

Changing the default text to number conversion settings

The text to number conversion can be customized in the Detailed Calculation Settings option.

Please support us!