チャートのデータラベルのテキスト折り返しを無効にする

Contents
[ ]

Aspose.CellsはDataLabels.setTextWrapped()メソッドを提供しています。データラベルのテキストの折り返しを有効または無効にするには、TrueまたはFalseに設定します。

同様に、DataLabels.isTextWrapped()メソッドを使用して、データラベルが既に折り返されているかどうかを調べることができます。

このスクリーンショットは、データラベルのテキストが折り返されているサンプルMicrosoft Excelファイルを示しています。Microsoft Excel 2013のフォーマットデータラベルパネルのALIGNMENTセクションで、図形のテキストを折り返しオプションをチェックまたはクリアできることがわかります。

データラベルの折り返し

todo:image_alt_text

次のサンプルコードは、Aspose.Cellsを使用してサンプルMicrosoft Excelファイルを読み込み、DataLabels.setTextWrapped()メソッドを使用してデータラベルのテキストの折り返しを無効にします。コード実行後、チャートは以下のようになります。以前折り返されていたテキストが折り返されていません。

データラベルを1行に表示する

todo:image_alt_text

// 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(DisableTextWrapping.class);
// Load the sample Excel file inside the workbook object
Workbook workbook = new Workbook(dataDir + "SampleChart.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Access the first chart inside the worksheet
Chart chart = worksheet.getCharts().get(0);
// Disable the Text Wrapping of Data Labels in all Series
chart.getNSeries().get(0).getDataLabels().setTextWrapped(false);
chart.getNSeries().get(1).getDataLabels().setTextWrapped(false);
chart.getNSeries().get(2).getDataLabels().setTextWrapped(false);
// Save the workbook
workbook.save(dataDir + "Output.xlsx");