本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFWorkbook.getCreationHelper方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFWorkbook.getCreationHelper方法的具體用法?Java HSSFWorkbook.getCreationHelper怎麽用?Java HSSFWorkbook.getCreationHelper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.hssf.usermodel.HSSFWorkbook
的用法示例。
在下文中一共展示了HSSFWorkbook.getCreationHelper方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCelStyleForTime
import org.apache.poi.hssf.usermodel.HSSFWorkbook; //導入方法依賴的package包/類
public static HSSFCellStyle createCelStyleForTime(HSSFWorkbook workBook)
{
HSSFCellStyle cellStyle = workBook.createCellStyle();
CreationHelper createHelper = workBook.getCreationHelper();
cellStyle.setDataFormat(
createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
return cellStyle;
}
示例2: createHSSFCellStyles
import org.apache.poi.hssf.usermodel.HSSFWorkbook; //導入方法依賴的package包/類
private Map<String, CellStyle> createHSSFCellStyles(Workbook wb, int[] contextBgColor, int[] contextFontColor, int contextFontSize, int contextFontAlign, int[] headerBgColor,
int[] headerFontColor, int headerFontSize, int headerAlign) {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
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;
}