获取条件格式中使用的图标集、数据条或色标对象
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); |