title: Apache POI: How to add Diagonal Border
body: <p>I would like to use <code>Apache POI</code> to draw <code>Diagonal Border</code> but I couldn't find any function can support that feature.</p>
  
  <p><a href="https://i.stack.imgur.com/9ecmz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ecmz.png" alt="enter image description here"></a></p>
  
  <p>I tried this <a href="https://poi.apache.org/apidocs/org/apache/poi/hssf/record/cf/BorderFormatting.html#setBorderDiagonal(int)" rel="nofollow noreferrer">setBorderDiagonal</a> but it isn't working.</p>
  
  <pre><code>XSSFSheetConditionalFormatting my_cond_format_layer = my_sheet.getSheetConditionalFormatting();
  
  XSSFConditionalFormattingRule my_rule = my_cond_format_layer.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "14", "16");
  XSSFConditionalFormattingRule my_rule_2 = my_cond_format_layer.createConditionalFormattingRule(ComparisonOperator.EQUAL, "33");
  XSSFPatternFormatting fill_pattern_2 = my_rule_2.createPatternFormatting();
  fill_pattern_2.setFillBackgroundColor(IndexedColors.YELLOW.getIndex());
  
  XSSFBorderFormatting borderFormatting = my_rule_2.createBorderFormatting();
  borderFormatting.setDiagonalBorderColor(IndexedColors.BLUE.getIndex());
  borderFormatting.setBorderDiagonal(BorderFormatting.BORDER_THICK);
  
  ConditionalFormattingRule[] multiple_rules = {my_rule, my_rule_2};
  CellRangeAddress[] my_data_range = {CellRangeAddress.valueOf("A1:A4")};
  my_cond_format_layer.addConditionalFormatting(my_data_range, multiple_rules);
  </code></pre>