/newsletter-portlet/src/main/java/com/rcs/newsletter/util/ExcelExporterUtil.java

https://github.com/mariuszs/rcsnewsletter · Java · 32 lines · 16 code · 6 blank · 10 comment · 0 complexity · 0a844c0ebc0439ad86469c629f43ff90 MD5 · raw file

  1. package com.rcs.newsletter.util;
  2. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  3. import org.apache.poi.hssf.usermodel.HSSFFont;
  4. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  5. import org.apache.poi.hssf.util.HSSFColor;
  6. /**
  7. *
  8. * @author Ariel Parra <ariel@rotterdam-cs.com>
  9. */
  10. public class ExcelExporterUtil {
  11. /**
  12. * Method that create the cell style for the excel Header.
  13. * Puts the title center aligned and the font on bold style
  14. * @param workbook
  15. * @return
  16. */
  17. public static HSSFCellStyle createHeaderStyle(final HSSFWorkbook workbook) {
  18. final HSSFCellStyle cellStyle = workbook.createCellStyle();
  19. HSSFFont font = workbook.createFont();
  20. font.setColor(HSSFColor.BLACK.index);
  21. font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  22. cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  23. cellStyle.setFont(font);
  24. return cellStyle;
  25. }
  26. }