条件付き書式で使用されるアイコン セット、データ バー、またはカラー スケール オブジェクトを取得する
Contents
[
Hide
]
場合によっては、セルまたはセル範囲の条件付き書式設定で使用されるアイコン セットを取得する必要があり、それに基づいて画像ファイルを作成する必要があります。条件付き書式で使用されるデータ バーまたはカラー スケールを読み取る必要がある場合があります。 Aspose.Cells はこの機能をサポートしています。
次のコード サンプルは、条件付き書式設定に使用されるアイコン セットを読み取る方法を示しています。 Aspose.Cellの簡易APIで、アイコンセットの画像データを画像として保存します。
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); | |
// Open a template Excel file | |
Workbook workbook = new Workbook(dataDir+ "book1.xlsx"); | |
// Get the first worksheet in the workbook | |
Worksheet sheet = workbook.Worksheets[0]; | |
// Get the A1 cell | |
Cell cell = sheet.Cells["A1"]; | |
// Get the conditional formatting result object | |
ConditionalFormattingResult cfr = cell.GetConditionalFormattingResult(); | |
// Get the icon set | |
ConditionalFormattingIcon icon = cfr.ConditionalFormattingIcon; | |
// Create the image file based on the icon's image data | |
File.WriteAllBytes(dataDir+ "imgIcon.out.jpg", icon.ImageData); |