ワードアートの透かしをグラフに追加する
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"); |