Range.Formula 属性


返回或设置 A1 样式表示法和宏语言中的对象的公式。Returns or sets the object's formula in A1-style notation and in the language of the macro.

 property System::Object ^ Formula { System::Object ^ get(); void set(System::Object ^ value); };
public object Formula { get; set; }
Public Property Formula As Object




此属性对于 OLAP 数据源无效。This property is not available for OLAP data sources.

如果单元格包含一个常量,此属性返回该常量。If the cell contains a constant, this property returns the constant. 如果单元格为空,此 Formula 属性返回一个空字符串。If the cell is empty, this Formula property returns an empty string. 如果单元格包含公式,Formula 属性将该公式作为字符串返回,所用格式与在编辑栏(包括等号)中显示时的格式相同。If the cell contains a formula, the Formula property returns the formula as a string in the same format that would be displayed in the formula bar (including the equal sign).

如果将单元格的值或者公式设置为日期类型,则 Microsoft Excel 将检查此单元格的数字格式是否符合日期或者时间格式。如果不符合,Microsoft Excel 将把数字格式设置为默认的短日期格式。If you set the value or formula of a cell to a date, Microsoft Excel checks to see whether that cell is already formatted with one of the date or time number formats. If not, Microsoft Excel changes the number format to the default short date number format.

如果区域是一维或二维区域,可以将公式设置为相同维度的数组。If the range is a one- or two-dimensional range, you can set the formula to an array of the same dimensions. 同样,可以将公式放入 Basic 数组中。Similarly, you can put the formula into a Basic array.

如果为多单元格区域设置公式,则会用公式填充该区域所有的单元格。Setting the formula for a multiple-cell range fills all cells in the range with the formula.