将艺术字水印添加到图表
Contents
[
Hide
]
您可以使用艺术字向电子表格添加特殊文本效果。例如,拉伸标题、装饰文本、使文本适合预设形状,或将受影响的文本作为水印应用到图表的绘图区域。艺术字成为一个对象,您可以在电子表格中移动或放置它以添加装饰。
以下示例显示如何将艺术字形状添加为图表绘图区域的水印。
向图表添加艺术字水印
以下示例显示如何将艺术字形状添加为现有图表绘图区域的水印。该示例使用已包含图表的模板 Excel 文件。
代码执行前后对比图
输入文件
输出文件
Java 向图表添加艺术字水印的代码
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.getSharedDataDir(AddWordArtWatermarkToChart.class) + "articles/"; | |
// Instantiate a new workbook, Open the existing excel file. | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Get the chart in the first worksheet. | |
Chart chart = workbook.getWorksheets().get(0).getCharts().get(0); | |
// Add a WordArt watermark (shape) to the chart's plot area. | |
Shape wordart = chart.getShapes().addTextEffectInChart(MsoPresetTextEffect.TEXT_EFFECT_1, "CONFIDENTIAL", | |
"Arial Black", 66, false, false, 1200, 500, 2000, 3000); | |
// Get the shape's fill format. | |
FillFormat wordArtFormat = wordart.getFill(); | |
// Set the transparency. | |
wordArtFormat.setTransparency(0.9); | |
// Get the line format. | |
LineFormat lineFormat = wordart.getLine(); | |
// Set Line format to invisible. | |
lineFormat.setWeight(0.0); | |
// Save the excel file. | |
workbook.save(dataDir + "AWArtWToC_out.xlsx"); |