// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("C4").setValue("FY 2019"); worksheet.getRange("C5").setValue("Sales"); worksheet.getRange("C6").setValue("Monthly"); String[] months = { "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan", "Feb", "Mar" }; int[] monthlySales = { 188897, 208146, 226196, 277318, 263273, 259845, 241047, 256306, 195845, 204934, 257852, 227779 }; for (int i = 0; i < months.length; i++) { worksheet.getRange("B" + (7 + i)).setValue(months[i]); worksheet.getRange("C" + (7 + i)).setValue(monthlySales[i]); } // Set color using string worksheet.getRange("B4:C6").getInterior().setColor(Color.GetLightBlue()); worksheet.getRange("C4:C6").getBorders().setColor(Color.GetBlack()); worksheet.getRange("B7:B18").getInterior().setColor(Color.GetLightGray()); worksheet.getRange("B7:C18").getBorders().setColor(Color.GetBlack()); worksheet.getRange("B4:B6").getBorders().get(BordersIndex.EdgeLeft).setLineStyle(BorderLineStyle.Thin); worksheet.getRange("B4:B6").getBorders().get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.Thin); worksheet.getRange("B4:B6").merge(); worksheet.getRange("C2:D18").setColumnWidth(15); worksheet.getRange("B2:D18").setHorizontalAlignment(HorizontalAlignment.Center); worksheet.getRange("B2:C18").setVerticalAlignment(VerticalAlignment.Center); worksheet.getRange("B4:C6").getFont().setBold(true); worksheet.getRange("C7:C18").setNumberFormat("#,##0"); worksheet.getRange("C2").setHorizontalAlignment(HorizontalAlignment.Right); // Use cell decoration to highlight the highest sales ICornerFold cornerFold1 = new CornerFold(Color.GetRed(), EnumSet.of(CornerPosition.LeftTop), 8); ICellDecorationIcon cellDecorationIcon1 = new CellDecorationIcon( "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjEyIiBoZWlnaHQ9IjEyIiBmaWxsPSJ0cmFuc3BhcmVudCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTcgOUg1TDUgNS45NjA0NmUtMDhIN0w3IDlaTTYgMTBDNi41NTIyOCAxMCA3IDEwLjQ0NzcgNyAxMUM3IDExLjU1MjMgNi41NTIyOCAxMiA2IDEyQzUuNDQ3NzIgMTIgNSAxMS41NTIzIDUgMTFDNSAxMC40NDc3IDUuNDQ3NzIgMTAgNiAxMFoiIGZpbGw9InJlZCIvPgo8L3N2Zz4K", 12, 12, IconPosition.OutsideRight); worksheet.getRange("C10").setDecoration(new com.grapecity.documents.excel.CellDecoration(cornerFold1, Collections.singletonList(cellDecorationIcon1))); worksheet.getRange("D10").setValue("Highest"); // Use cell decoration to highlight the lowest sales ICornerFold cornerFold2 = new CornerFold(Color.GetGreen(), EnumSet.of(CornerPosition.LeftTop), 8); ICellDecorationIcon cellDecorationIcon2 = new CellDecorationIcon( "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjEyIiBoZWlnaHQ9IjEyIiBmaWxsPSJ0cmFuc3BhcmVudCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTcgOUg1TDUgNS45NjA0NmUtMDhIN0w3IDlaTTYgMTBDNi41NTIyOCAxMCA3IDEwLjQ0NzcgNyAxMUM3IDExLjU1MjMgNi41NTIyOCAxMiA2IDEyQzUuNDQ3NzIgMTIgNSAxMS41NTIzIDUgMTFDNSAxMC40NDc3IDUuNDQ3NzIgMTAgNiAxMFoiIGZpbGw9ImdyZWVuIi8+Cjwvc3ZnPgo=", 12, 12, IconPosition.OutsideRight); worksheet.getRange("C7").setDecoration(new com.grapecity.documents.excel.CellDecoration(cornerFold2, Collections.singletonList(cellDecorationIcon2))); worksheet.getRange("D7").setValue("Lowest"); // Save to a .sjs file workbook.save("CellDecoration.sjs");