ExcelScript.TextFrame interface

表示形状对象的文本框。

注解

使用方

示例

/**
 * This script creates a star shape with the value from cell A1.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the value of A1 from the worksheet named Sheet1.
  const sheet = workbook.getWorksheet("Sheet1");
  const value = sheet.getRange("A1").getValue();

  // Create a Shape object that looks like a 5-pointed star.
  const star = sheet.addGeometricShape(ExcelScript.GeometricShapeType.star5);

  // Set the text of star and make sure the shape fits the text.
  const textFrame: ExcelScript.TextFrame = star.getTextFrame();
  textFrame.getTextRange().setText(value.toString());
  textFrame.setAutoSizeSetting(ExcelScript.ShapeAutoSize.autoSizeShapeToFitText);
}

方法

deleteText()

删除文本框中的所有文本。

getAutoSizeSetting()

文本框的自动调整大小设置。 可以将文本框设置为自动调整文本大小以适应文本框,或自动调整文本框大小以适应文本,或者不使用自动调整大小设置。

getBottomMargin()

表示文本框的下边距(以磅为单位)。

getHasText()

指定文本框是否包含文本。

getHorizontalAlignment()

表示文本框的水平对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalAlignment。

getHorizontalOverflow()

表示文本框的水平溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalOverflow。

getLeftMargin()

表示文本框的左边距(以磅为单位)。

getOrientation()

表示文本框架所指向的角度。 有关详细信息,请参阅 ExcelScript.ShapeTextOrientation。

getReadingOrder()

表示文本框从左到右或从右到左的读取顺序。 有关详细信息,请参阅 ExcelScript.ShapeTextReadingOrder。

getRightMargin()

表示文本框的右边距(以磅为单位)。

getTextRange()

表示附加到文本框中形状上的文本,以及用于操作文本的属性和方法。 有关详细信息,请参阅 ExcelScript.TextRange。

getTopMargin()

表示文本框的上边距(以磅为单位)。

getVerticalAlignment()

表示文本框的垂直对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalAlignment。

getVerticalOverflow()

表示文本框的垂直溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalOverflow。

setAutoSizeSetting(autoSizeSetting)

文本框的自动调整大小设置。 可以将文本框设置为自动调整文本大小以适应文本框,或自动调整文本框大小以适应文本,或者不使用自动调整大小设置。

setBottomMargin(bottomMargin)

表示文本框的下边距(以磅为单位)。

setHorizontalAlignment(horizontalAlignment)

表示文本框的水平对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalAlignment。

setHorizontalOverflow(horizontalOverflow)

表示文本框的水平溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalOverflow。

setLeftMargin(leftMargin)

表示文本框的左边距(以磅为单位)。

setOrientation(orientation)

表示文本框架所指向的角度。 有关详细信息,请参阅 ExcelScript.ShapeTextOrientation。

setReadingOrder(readingOrder)

表示文本框从左到右或从右到左的读取顺序。 有关详细信息,请参阅 ExcelScript.ShapeTextReadingOrder。

setRightMargin(rightMargin)

表示文本框的右边距(以磅为单位)。

setTopMargin(topMargin)

表示文本框的上边距(以磅为单位)。

setVerticalAlignment(verticalAlignment)

表示文本框的垂直对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalAlignment。

setVerticalOverflow(verticalOverflow)

表示文本框的垂直溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalOverflow。

方法详细信息

deleteText()

删除文本框中的所有文本。

deleteText(): void;

返回

void

getAutoSizeSetting()

文本框的自动调整大小设置。 可以将文本框设置为自动调整文本大小以适应文本框,或自动调整文本框大小以适应文本,或者不使用自动调整大小设置。

getAutoSizeSetting(): ShapeAutoSize;

返回

getBottomMargin()

表示文本框的下边距(以磅为单位)。

getBottomMargin(): number;

返回

number

getHasText()

指定文本框是否包含文本。

getHasText(): boolean;

返回

boolean

getHorizontalAlignment()

表示文本框的水平对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalAlignment。

getHorizontalAlignment(): ShapeTextHorizontalAlignment;

返回

getHorizontalOverflow()

表示文本框的水平溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalOverflow。

getHorizontalOverflow(): ShapeTextHorizontalOverflow;

返回

getLeftMargin()

表示文本框的左边距(以磅为单位)。

getLeftMargin(): number;

返回

number

getOrientation()

表示文本框架所指向的角度。 有关详细信息,请参阅 ExcelScript.ShapeTextOrientation。

getOrientation(): ShapeTextOrientation;

返回

getReadingOrder()

表示文本框从左到右或从右到左的读取顺序。 有关详细信息,请参阅 ExcelScript.ShapeTextReadingOrder。

getReadingOrder(): ShapeTextReadingOrder;

返回

getRightMargin()

表示文本框的右边距(以磅为单位)。

getRightMargin(): number;

返回

number

getTextRange()

表示附加到文本框中形状上的文本,以及用于操作文本的属性和方法。 有关详细信息,请参阅 ExcelScript.TextRange。

getTextRange(): TextRange;

返回

getTopMargin()

表示文本框的上边距(以磅为单位)。

getTopMargin(): number;

返回

number

getVerticalAlignment()

表示文本框的垂直对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalAlignment。

getVerticalAlignment(): ShapeTextVerticalAlignment;

返回

getVerticalOverflow()

表示文本框的垂直溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalOverflow。

getVerticalOverflow(): ShapeTextVerticalOverflow;

返回

setAutoSizeSetting(autoSizeSetting)

文本框的自动调整大小设置。 可以将文本框设置为自动调整文本大小以适应文本框,或自动调整文本框大小以适应文本,或者不使用自动调整大小设置。

setAutoSizeSetting(autoSizeSetting: ShapeAutoSize): void;

参数

autoSizeSetting
ExcelScript.ShapeAutoSize

返回

void

setBottomMargin(bottomMargin)

表示文本框的下边距(以磅为单位)。

setBottomMargin(bottomMargin: number): void;

参数

bottomMargin

number

返回

void

setHorizontalAlignment(horizontalAlignment)

表示文本框的水平对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalAlignment。

setHorizontalAlignment(
            horizontalAlignment: ShapeTextHorizontalAlignment
        ): void;

参数

返回

void

setHorizontalOverflow(horizontalOverflow)

表示文本框的水平溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextHorizontalOverflow。

setHorizontalOverflow(
            horizontalOverflow: ShapeTextHorizontalOverflow
        ): void;

参数

返回

void

setLeftMargin(leftMargin)

表示文本框的左边距(以磅为单位)。

setLeftMargin(leftMargin: number): void;

参数

leftMargin

number

返回

void

setOrientation(orientation)

表示文本框架所指向的角度。 有关详细信息,请参阅 ExcelScript.ShapeTextOrientation。

setOrientation(orientation: ShapeTextOrientation): void;

参数

返回

void

setReadingOrder(readingOrder)

表示文本框从左到右或从右到左的读取顺序。 有关详细信息,请参阅 ExcelScript.ShapeTextReadingOrder。

setReadingOrder(readingOrder: ShapeTextReadingOrder): void;

参数

返回

void

setRightMargin(rightMargin)

表示文本框的右边距(以磅为单位)。

setRightMargin(rightMargin: number): void;

参数

rightMargin

number

返回

void

setTopMargin(topMargin)

表示文本框的上边距(以磅为单位)。

setTopMargin(topMargin: number): void;

参数

topMargin

number

返回

void

setVerticalAlignment(verticalAlignment)

表示文本框的垂直对齐方式。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalAlignment。

setVerticalAlignment(
            verticalAlignment: ShapeTextVerticalAlignment
        ): void;

参数

返回

void

setVerticalOverflow(verticalOverflow)

表示文本框的垂直溢出行为。 有关详细信息,请参阅 ExcelScript.ShapeTextVerticalOverflow。

setVerticalOverflow(verticalOverflow: ShapeTextVerticalOverflow): void;

参数

返回

void