code: public void writeAttributeHeaders(
        Iterable<Attribute> attributes, AttributeWriteMode attributeWriteMode) {
      if (attributes == null) throw new IllegalArgumentException("Attributes cannot be null");
      if (attributeWriteMode == null)
        throw new IllegalArgumentException("AttributeWriteMode cannot be null");
  
      if (cachedAttributes == null) {
        Row poiRow = sheet.createRow(row++);
  
        // write header
        int i = 0;
        for (Attribute attribute : attributes) {
          Cell cell = poiRow.createCell(i++, CellType.STRING);
  
          switch (attributeWriteMode) {
            case ATTRIBUTE_LABELS:
              cell.setCellValue(
                  AbstractCellProcessor.processCell(attribute.getLabel(), true, cellProcessors));
              break;
            case ATTRIBUTE_NAMES:
              cell.setCellValue(
                  AbstractCellProcessor.processCell(attribute.getName(), true, cellProcessors));
              break;
            default:
              throw new UnexpectedEnumException(attributeWriteMode);
          }
        }
  
        // store header
        this.cachedAttributes = attributes;
      }
    }
docs: Write sheet column headers