公共 API Aspose.Cells 8.9.2 的变化

添加的 API

添加了 TextOptions 类和 FontSettings.TextOptions 属性

Aspose.Cells for Java 公开了 TextOptions 类以及 FontSettings.TextOptions 属性,以控制 Shape 文本部分的外观。

这是 FontSettings.TextOptions 属性的简单使用场景。

Java

 //Initialize Workbook instance

Workbook book = new Workbook();

//Access first worksheet from collection

Worksheet sheet = book.getWorksheets().get(0);

//Add a Shape of type TextBox to the collection 

Shape shape = sheet.getShapes().addShape(MsoDrawingType.TEXT_BOX, 0, 0, 0, 0, 100, 200);

//Add text to Shape

shape.setText("Aspose");

//Access TextOptions of Shape

TextOptions textOptions =  ((FontSetting)shape.getCharacters().get(0)).getTextOptions();

添加了 TextOptions.Fill、Outline 和 Shadow 属性

Aspose.Cells for Java 8.9.2 公开了 TextOptions.Fill、TextOptions.Outline 和 TextOptions.Shadow 属性,这些属性允许分别控制形状文本内容的各个方面,例如填充、阴影和轮廓。

这是上述属性的简单使用场景。

Java

 //Initialize Workbook instance

Workbook book = new Workbook();

//Access first worksheet from collection

Worksheet sheet = book.getWorksheets().get(0);

//Add a Shape of type TextBox to the collection 

Shape shape = sheet.getShapes().addShape(MsoDrawingType.TEXT_BOX, 0, 0, 0, 0, 100, 200);

//Add text to Shape

shape.setText("Aspose");

//Access TextOptions of Shape

TextOptions textOptions =  ((FontSetting)shape.getCharacters().get(0)).getTextOptions();

//Set shadow 

textOptions.getShadow().setPresetType(PresetShadowType.BELOW);

//Set fill color

textOptions.getFill().setFillType(FillType.SOLID);

textOptions.getFill().getSolidFill().setColor(Color.getRed());

//Set outline color

textOptions.getOutline().setOneColorGradient(Color.getBlue(), 0.3, GradientStyleType.HORIZONTAL, 2);

添加了 Shape.Line 属性

Aspose.Cells for Java 公开了 Shape.Line 属性,该属性返回 LineFormat 的实例以控制 Shape 轮廓的外观。

下面是 Shape.Line 属性的简单使用场景。

Java

 //Initialize Workbook instance

Workbook book = new Workbook();

//Access first worksheet from collection

Worksheet sheet = book.getWorksheets().get(0);

//Add a Shape of type TextBox to the collection 

Shape shape = sheet.getShapes().addShape(MsoDrawingType.TEXT_BOX, 0, 0, 0, 0, 100, 200);

//Access LineFormat of Shape

LineFormat line = shape.getLine();

//Set weight of line

line.setWeight(4);

添加了 Shape.Fill 属性

Aspose.Cells for Java 8.9.2 公开了返回 FillFormat 实例的 Shape.Fill 属性,以控制形状区域的不同方面。

以下是 Shape.Fill 属性的简单使用场景。

Java

 //Initialize Workbook instance

Workbook book = new Workbook();

//Access first worksheet from collection

Worksheet sheet = book.getWorksheets().get(0);

//Add a Shape of type TextBox to the collection 

Shape shape = sheet.getShapes().addShape(MsoDrawingType.TEXT_BOX, 0, 0, 0, 0, 100, 200);

//Access FillFormat of Shape

FillFormat fill = shape.getFill();

//Set color for fill

fill.setFillType(FillType.SOLID);

fill.getSolidFill().setColor(Color.getBlue());

过时的 API

废弃的 ShapeFont 类

请改用 TextOptions 类。

废弃的 ShapeFormat 类

请直接使用 Shape.Fill 和 Shape.Line 属性。

废弃的 Shape.Format 属性

请直接使用 Shape.Fill 和 Shape.Line 属性。

废弃的 Shape.LineFormat 属性

请改用 Shape.Line 属性。

废弃的 Shape.FillFormat 属性

请改用 Shape.Fill 属性。

废弃的 FontSetting.ShapeFont 属性

请改用 FontSetting.TextOptions 属性。