Excel API Library for Java - Sample Browser | Document Solutions | Create icon set rule

[フレーム] src="bundle.js"> The icon sets rule in conditional formatting displays the icons on the basis of values entered in the cells. Each value represents a distinct icon that appears in a cell if it matches the icon sets rule applied on it. This rule can be added using the properties and methods of the IIconSetCondition interface. // Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); Object data = new Object[][]{ {"Name", "City", "Birthday", "Eye color", "Weight", "Height"}, {"Richard", "New York", new GregorianCalendar(1968, 5, 8), "Blue", 67, 165}, {"Nia", "New York", new GregorianCalendar(1972, 6, 3), "Brown", 62, 134}, {"Jared", "New York", new GregorianCalendar(1964, 2, 2), "Hazel", 72, 180}, {"Natalie", "Washington", new GregorianCalendar(1972, 7, 8), "Blue", 66, 163}, {"Damon", "Washington", new GregorianCalendar(1986, 1, 2), "Hazel", 76, 176}, {"Angela", "Washington", new GregorianCalendar(1993, 1, 15), "Brown", 68, 145} }; worksheet.getRange("A1:F7").setValue(data); worksheet.getColumns().get(2).autoFit(); //icon set rule. IIconSetCondition condition = worksheet.getRange("E2:E7").getFormatConditions().addIconSetCondition(); condition.setIconSet(workbook.getIconSets().get(IconSetType.Icon3Symbols)); condition.getIconCriteria().get(1).setOperator(FormatConditionOperator.GreaterEqual); condition.getIconCriteria().get(1).setValue(30); condition.getIconCriteria().get(1).setType(ConditionValueTypes.Percent); condition.getIconCriteria().get(2).setOperator(FormatConditionOperator.GreaterEqual); condition.getIconCriteria().get(2).setValue(70); condition.getIconCriteria().get(2).setType(ConditionValueTypes.Percent); // Save to an excel file workbook.save("CreateIconSetRule.xlsx"); // Create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) val data = arrayOf(arrayOf("Name", "City", "Birthday", "Eye color", "Weight", "Height"), arrayOf("Richard", "New York", GregorianCalendar(1968, 5, 8), "Blue", 67, 165), arrayOf("Nia", "New York", GregorianCalendar(1972, 6, 3), "Brown", 62, 134), arrayOf("Jared", "New York", GregorianCalendar(1964, 2, 2), "Hazel", 72, 180), arrayOf("Natalie", "Washington", GregorianCalendar(1972, 7, 8), "Blue", 66, 163), arrayOf("Damon", "Washington", GregorianCalendar(1986, 1, 2), "Hazel", 76, 176), arrayOf("Angela", "Washington", GregorianCalendar(1993, 1, 15), "Brown", 68, 145)) worksheet.getRange("A1:F7").value = data worksheet.columns[2].autoFit() //icon set rule. val condition = worksheet.getRange("E2:E7").formatConditions.addIconSetCondition() condition.iconSet = workbook.iconSets.get(IconSetType.Icon3Symbols) condition.iconCriteria.get(1).operator = FormatConditionOperator.GreaterEqual condition.iconCriteria.get(1).value = 30 condition.iconCriteria.get(1).type = ConditionValueTypes.Percent condition.iconCriteria.get(2).operator = FormatConditionOperator.GreaterEqual condition.iconCriteria.get(2).value = 70 condition.iconCriteria.get(2).type = ConditionValueTypes.Percent // Save to an excel file workbook.save("CreateIconSetRule.xlsx")

AltStyle によって変換されたページ (->オリジナル) /