package com.huatek.busi.common.util;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

/**
 * @ClassName: ExcelStyle
 * @FullClassPath: com.frame.core.utils.xx
 * @Description: execl样式
 * @author: Arno
 * @date: Nov 9, 2017 9:55:22 AM
 * @version: 1.0
 */

public class ExcelStyle  
{  
   /** 
    * 设置头部样式 
    * @param workbook 工作表 
    * @param style 样式 
    * @return 
    */  
   @SuppressWarnings("deprecation")
	public static HSSFCellStyle setHeadStyle( HSSFWorkbook workbook,  
           HSSFCellStyle style )  
   {  
 
       style.setFillForegroundColor( HSSFColor.WHITE.index );  
       style.setFillPattern( HSSFCellStyle.SOLID_FOREGROUND );  
       style.setBorderBottom( HSSFCellStyle.BORDER_THIN );  
       style.setBorderLeft( HSSFCellStyle.BORDER_THIN );  
       style.setBorderRight( HSSFCellStyle.BORDER_THIN );  
       style.setBorderTop( HSSFCellStyle.BORDER_THIN );  
       style.setAlignment( HSSFCellStyle.ALIGN_CENTER );  
       // 生成字体  
       HSSFFont font = workbook.createFont();  
       //font.setColor( HSSFColor.VIOLET.index );  
       font.setFontHeightInPoints( (short)12 );  
       font.setBoldweight( HSSFFont.BOLDWEIGHT_BOLD );  
       // 把字体应用到当前的样样式  
       font.setFontName("宋体");
       style.setFont( font );  
       return style;  
 
   }  
   
   
   /** 
    * 设置体部样式 
    * @param workbook 工作表 
    * @param style  单元格样式 
    * @return 
    */  
   @SuppressWarnings("deprecation")
	public static HSSFCellStyle setbodyStyle( HSSFWorkbook workbook,  
           HSSFCellStyle style )  
   {  
       style.setFillForegroundColor( HSSFColor.WHITE.index );  
       style.setFillPattern( HSSFCellStyle.SOLID_FOREGROUND );  
       style.setBorderBottom( HSSFCellStyle.BORDER_THIN );  
       style.setBorderLeft( HSSFCellStyle.BORDER_THIN );  
       style.setBorderRight( HSSFCellStyle.BORDER_THIN );  
       style.setBorderTop( HSSFCellStyle.BORDER_THIN );  
       style.setAlignment( HSSFCellStyle.ALIGN_CENTER );  
       style.setVerticalAlignment( HSSFCellStyle.VERTICAL_CENTER );  
       // 生成字体  
       HSSFFont font = workbook.createFont();  
       font.setBoldweight( HSSFFont.BOLDWEIGHT_NORMAL );  
       font.setFontHeightInPoints( (short)11 ); 
       font.setFontName("宋体");
       // 把字体应用到当前的样样式  
       style.setFont( font );  
       return style;  
   }  
}  

