import org.apache.poi.hssf.usermodel.HSSFWorkbook; //导入方法依赖的package包/类
private Map createHSSFCellStyles(Workbook wb, int[] contextBgColor, int[] contextFontColor, int contextFontSize, int contextFontAlign, int[] headerBgColor,
int[] headerFontColor, int headerFontSize, int headerAlign) {
Map styles = new HashMap();
HSSFWorkbook workbook = (HSSFWorkbook) wb;
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex((short) 11, (byte) contextBgColor[0], (byte) contextBgColor[1], (byte) contextBgColor[2]);
palette.setColorAtIndex((short) 12, (byte) contextFontColor[0], (byte) contextFontColor[1], (byte) contextFontColor[2]);
palette.setColorAtIndex((short) 13, (byte) headerBgColor[0], (byte) headerBgColor[1], (byte) headerBgColor[2]);
palette.setColorAtIndex((short) 14, (byte) headerFontColor[0], (byte) headerFontColor[1], (byte) headerFontColor[2]);
HSSFFont headerFont = workbook.createFont();
headerFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
headerFont.setFontName("宋体");
headerFont.setColor((short) 14);
headerFont.setBold(true);
headerFont.setFontHeightInPoints((short) headerFontSize);
CellStyle headerStyle = this.createBorderCellStyle(workbook, true);
headerStyle.setFont(headerFont);
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setFillForegroundColor((short) 13);
this.setCellStyleAligment(headerStyle, headerAlign);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
styles.put(GridStyleType.headerStyle.name(), headerStyle);
HSSFFont dataFont = workbook.createFont();
dataFont.setColor((short) 12);
dataFont.setFontHeightInPoints((short) contextFontSize);
dataFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
dataFont.setFontName("宋体");
CellStyle dataAlignLeftStyle = this.createBorderCellStyle(workbook, true);
dataAlignLeftStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignLeftStyle.setFillForegroundColor((short) 11);
dataAlignLeftStyle.setFont(dataFont);
dataAlignLeftStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignLeftStyle.setWrapText(true);
dataAlignLeftStyle.setAlignment(HorizontalAlignment.LEFT);
styles.put(GridStyleType.dataAlignLeftStyle.name(), dataAlignLeftStyle);
CellStyle dataAlignCenterStyle = this.createBorderCellStyle(workbook, true);
dataAlignCenterStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignCenterStyle.setFillForegroundColor((short) 11);
dataAlignCenterStyle.setFont(dataFont);
dataAlignCenterStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignCenterStyle.setWrapText(true);
dataAlignCenterStyle.setAlignment(HorizontalAlignment.CENTER);
styles.put(GridStyleType.dataAlignCenterStyle.name(), dataAlignCenterStyle);
CellStyle dataAlignRightStyle = this.createBorderCellStyle(workbook, true);
dataAlignRightStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignRightStyle.setFillForegroundColor((short) 11);
dataAlignRightStyle.setFont(dataFont);
dataAlignRightStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignRightStyle.setWrapText(true);
dataAlignRightStyle.setAlignment(HorizontalAlignment.RIGHT);
styles.put(GridStyleType.dataAlignRightStyle.name(), dataAlignRightStyle);
CellStyle dateStyle = this.createBorderCellStyle(workbook, true);
CreationHelper helper = workbook.getCreationHelper();
dateStyle.setDataFormat(helper.createDataFormat().getFormat("m/d/yy h:mm"));
dateStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dateStyle.setFillForegroundColor((short) 11);
dateStyle.setFont(dataFont);
dateStyle.setVerticalAlignment(VerticalAlignment.CENTER);
this.setCellStyleAligment(dateStyle, contextFontAlign);
styles.put(GridStyleType.dateStyle.name(), dateStyle);
return styles;
}