グラフのデータ ラベルの形状をテキストに合わせてサイズ変更する
Contents
[
Hide
]
Excel アプリケーションが提供するテキストに合わせて図形のサイズを変更するテキストが内部に収まるように形状のサイズを大きくするには、Chart の DataLabels のオプション。
Microsoft Excel のテキストに合わせてグラフのデータ ラベル図形のサイズを変更する
このオプションは、グラフのデータ ラベルのいずれかを選択することにより、Excel インターフェイスでアクセスできます。右クリックして、DataLabels の書式設定メニュー。の上サイズと特性タブ、展開アライメントを含む関連プロパティを明らかにする図形のサイズを変更してテキストを修正するオプション。
グラフのデータ ラベルの形状をテキストに合わせてサイズ変更する
データ ラベルの形状をテキストに合わせてサイズ変更する Excel の機能を模倣するために、Aspose.Cells API は Boolean 型を公開しました。DataLabels.IsResizeShapeToFitText財産。次のコードは、の単純な使用シナリオを示しています。DataLabels.IsResizeShapeToFitText財産。
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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create an instance of Workbook containing the Chart | |
var book = new Workbook(dataDir + "source.xlsx"); | |
// Access the Worksheet that contains the Chart | |
var sheet = book.Worksheets[0]; | |
foreach (Chart chart in sheet.Charts) | |
{ | |
for (int index = 0; index < chart.NSeries.Count; index++) | |
{ | |
// Access the DataLabels of indexed NSeries | |
var labels = chart.NSeries[index].DataLabels; | |
// Set ResizeShapeToFitText property to true | |
labels.IsResizeShapeToFitText = true; | |
} | |
// Calculate Chart | |
chart.Calculate(); | |
} | |
// Save the result | |
book.Save(dataDir + "output_out.xlsx"); |