更改形状的调整值
Contents
[
Hide
]
Aspose.Cells提供Shape.getGeometry().getShapeAdjustValues()属性来更改形状的调整点。在 Microsoft Excel UI 中,调整显示为黄色菱形节点。例如:
- 圆角矩形有个调整改变圆弧
- 三角形有一个调整改变点的位置
- 一个梯形有一个调整来改变顶部的宽度
- 箭头有两个调整来改变头部和尾部的形状
本文将解释使用Shape.getGeometry().getShapeAdjustValues()属性改变不同形状的调整值。
更改形状的调整值
以下示例代码访问源 Excel 文件中第一个工作表的前三个形状,然后更改形状的调整值。下面的屏幕截图显示了更改调整值之前和更改调整值之后形状的外观。
更改调整值之前绘制形状
更改调整值后绘制形状
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ChangeAdjustmentValuesOfShape.class); | |
// Create workbook object from source excel file | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Access first three shapes of the worksheet | |
Shape shape1 = worksheet.getShapes().get(0); | |
Shape shape2 = worksheet.getShapes().get(1); | |
Shape shape3 = worksheet.getShapes().get(2); | |
// Change the adjustment values of the shapes | |
shape1.getGeometry().getShapeAdjustValues().get(0).setValue(0.5d); | |
shape2.getGeometry().getShapeAdjustValues().get(0).setValue(0.8d); | |
shape3.getGeometry().getShapeAdjustValues().get(0).setValue(0.5d); | |
// Save the workbook | |
workbook.save(dataDir + "output.xlsx"); |