グラフのデータ ラベルのテキストの折り返しを無効にする
Contents
[
Hide
]
Microsoft Excel 2013 では、ユーザーはグラフのデータ ラベル内のテキストをラップまたはアンラップできます。デフォルトでは、データ ラベルのテキストは折り返されます。
Aspose.Cells はDataLabels.setTextWrapped()方法。に設定真実また間違いデータ ラベルのテキスト ラッピングをそれぞれ有効または無効にします。
同様に、DataLabels.isTextWrapped()メソッドを使用して、データ ラベルが既にラップされているかどうかを確認します。
このスクリーンショットは、データ ラベルのテキストが折り返されたグラフを含むサンプル Microsoft Excel ファイルを示しています。ご覧のとおり、テキストを図形で折り返すMicrosoft Excel 2013 の Format Datalabels パネルの ALIGNMENT セクションの ALIGNMENT オプション。
データ ラベルのラッピング
次のサンプル コードは、Aspose.Cells を使用してサンプル Microsoft Excel ファイルを読み込み、DataLabels.setTextWrapped()方法。コードが実行されると、チャートは次のようになります。以前にラップされたテキストがアンラップされます。
1 行だけにデータ ラベルを表示する
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(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"); |