本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFCellStyle.setVerticalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFCellStyle.setVerticalAlignment方法的具体用法?Java HSSFCellStyle.setVerticalAlignment怎么用?Java HSSFCellStyle.setVerticalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hssf.usermodel.HSSFCellStyle
的用法示例。
在下文中一共展示了HSSFCellStyle.setVerticalAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHSSFCellStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle createHSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
HSSFWorkbook workbook = (HSSFWorkbook) wb;
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex((short) 9, (byte) fontColor[0], (byte) fontColor[1], (byte) fontColor[2]);
palette.setColorAtIndex((short) 10, (byte) bgColor[0], (byte) bgColor[1], (byte) bgColor[2]);
HSSFFont titleFont = workbook.createFont();
titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
titleFont.setFontName("宋体");
titleFont.setColor((short) 9);
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) fontSize);
HSSFCellStyle titleStyle = (HSSFCellStyle) createBorderCellStyle(workbook, true);
titleStyle.setFont(titleFont);
titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleStyle.setFillForegroundColor((short) 10);
titleStyle.setAlignment(HorizontalAlignment.CENTER);
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return titleStyle;
}
示例2: createHeader
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static boolean createHeader(HSSFWorkbook workbook, HSSFSheet sheet,String[] header) throws Exception{
boolean flag = false;
try {
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFRow head_row = sheet.createRow(0); // 创建行
// 操作head
for (short h = 0; h < header.length; h++) {
createcsv(head_row, h, header[h], cellStyle);
}
flag = true;
} catch (Exception e) {
logger.error(sheet.getSheetName() + " : 抬头标题创建失败");
throw e;
}
return flag;
}
示例3: writeCondtions
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
* 表头条件
* @param sheet
* @param t
* @param cellCount
* @return
*/
void writeCondtions(HSSFSheet sheet){
T t = getConditions();
if (t!=null) {
HSSFRow row = sheet.createRow(getRowNumber());
row.setHeight((short) 500);
CellRangeAddress cra = new CellRangeAddress(getRowNumber(), getRowNumber(), 0, getColumnJson().size());
sheet.addMergedRegion(cra);
HSSFCell cell = row.createCell(0);
HSSFCellStyle style = cell.getCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setWrapText(true);
cell.setCellStyle(style);
setCellValue(cell, formatCondition(t));
addRowNumber();
}
}
示例4: createSecondTitleStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle createSecondTitleStyle(HSSFWorkbook wb){
HSSFCellStyle style = wb.createCellStyle();
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
style.setBorderBottom(HSSFCellStyle.BORDER_NONE);
style.setBorderLeft(HSSFCellStyle.BORDER_NONE);
style.setBorderRight(HSSFCellStyle.BORDER_NONE);
style.setBorderTop(HSSFCellStyle.BORDER_NONE);
style.setWrapText(true);
HSSFFont font = wb.createFont();
//font.setFontHeightInPoints((short)20);
font.setFontName("����");
style.setFont(font);
return style;
}
示例5: generateContStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
* @Description: 生成excel表格 单元格内容的样式
* @param workbook
* @return
*
* @History
* 1. 2014-12-19 linwb 创建方法
*/
private HSSFCellStyle generateContStyle(HSSFWorkbook workbook) {
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(contCellBackgroundColor);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
cellStyle.setBorderBottom(contBorderBottom);
cellStyle.setBorderLeft(contBorderLeft);
cellStyle.setBorderRight(contBorderRight);
cellStyle.setBorderTop(contBorderTop);
cellStyle.setAlignment(contCellTextAlign);
cellStyle.setVerticalAlignment(contCellVehicleAlign);
// 生成字体
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
// 把字体应用到当前的样式
cellStyle.setFont(font);
return cellStyle;
}
示例6: exportXLSLine
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
@Override
protected void exportXLSLine(final HSSFSheet sheet, final HSSFCellStyle cellStyle, final List<Object> cells,
final int offset) {
final HSSFRow row = sheet.createRow(sheet.getLastRowNum() + offset);
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
int count = 0;
for (final Object cellValue : cells) {
if (++count == 3) {
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
} else {
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
}
addColumn(cellStyle, row, cellValue);
}
}
示例7: setHeaderStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private void setHeaderStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setWrapText(true);
headerStyle = style;
}
示例8: copyCellStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static HSSFCellStyle copyCellStyle(final HSSFWorkbook workbook, final HSSFCellStyle style) {
final HSSFCellStyle newCellStyle = workbook.createCellStyle();
newCellStyle.setAlignment(style.getAlignment());
newCellStyle.setBorderBottom(style.getBorderBottom());
newCellStyle.setBorderLeft(style.getBorderLeft());
newCellStyle.setBorderRight(style.getBorderRight());
newCellStyle.setBorderTop(style.getBorderTop());
newCellStyle.setBottomBorderColor(style.getBottomBorderColor());
newCellStyle.setDataFormat(style.getDataFormat());
newCellStyle.setFillBackgroundColor(style.getFillBackgroundColor());
newCellStyle.setFillForegroundColor(style.getFillForegroundColor());
newCellStyle.setFillPattern(style.getFillPattern());
newCellStyle.setHidden(style.getHidden());
newCellStyle.setIndention(style.getIndention());
newCellStyle.setLeftBorderColor(style.getLeftBorderColor());
newCellStyle.setLocked(style.getLocked());
newCellStyle.setRightBorderColor(style.getRightBorderColor());
newCellStyle.setRotation(style.getRotation());
newCellStyle.setTopBorderColor(style.getTopBorderColor());
newCellStyle.setVerticalAlignment(style.getVerticalAlignment());
newCellStyle.setWrapText(style.getWrapText());
final HSSFFont font = workbook.getFontAt(style.getFontIndex());
newCellStyle.setFont(font);
return newCellStyle;
}
示例9: copyCellStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static HSSFCellStyle copyCellStyle(HSSFWorkbook workbook,
HSSFCellStyle style) {
HSSFCellStyle newCellStyle = workbook.createCellStyle();
newCellStyle.setAlignment(style.getAlignment());
newCellStyle.setBorderBottom(style.getBorderBottom());
newCellStyle.setBorderLeft(style.getBorderLeft());
newCellStyle.setBorderRight(style.getBorderRight());
newCellStyle.setBorderTop(style.getBorderTop());
newCellStyle.setBottomBorderColor(style.getBottomBorderColor());
newCellStyle.setDataFormat(style.getDataFormat());
newCellStyle.setFillBackgroundColor(style.getFillBackgroundColor());
newCellStyle.setFillForegroundColor(style.getFillForegroundColor());
newCellStyle.setFillPattern(style.getFillPattern());
newCellStyle.setHidden(style.getHidden());
newCellStyle.setIndention(style.getIndention());
newCellStyle.setLeftBorderColor(style.getLeftBorderColor());
newCellStyle.setLocked(style.getLocked());
newCellStyle.setRightBorderColor(style.getRightBorderColor());
newCellStyle.setRotation(style.getRotation());
newCellStyle.setTopBorderColor(style.getTopBorderColor());
newCellStyle.setVerticalAlignment(style.getVerticalAlignment());
newCellStyle.setWrapText(style.getWrapText());
HSSFFont font = workbook.getFontAt(style.getFontIndex());
newCellStyle.setFont(font);
return newCellStyle;
}
示例10: createCellStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle createCellStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setWrapText(true);
return style;
}
示例11: createHeadStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle createHeadStyle(HSSFWorkbook wb){
HSSFCellStyle style = wb.createCellStyle();
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setWrapText(true);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
return style;
}
示例12: createTitleStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle createTitleStyle(HSSFWorkbook wb){
HSSFCellStyle style = wb.createCellStyle();
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setWrapText(true);
HSSFFont font = wb.createFont();
font.setFontHeightInPoints((short)20);
font.setFontName("����");
style.setFont(font);
return style;
}
示例13: generateHeaderStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
* Description: 生成表格的 头部的单元格样式
* @param workbook
* @return
*
* @History
* 1. 2014-12-19 linwb 创建方法
*/
private HSSFCellStyle generateHeaderStyle(HSSFWorkbook workbook) {
//生成表格头部标题栏样式
HSSFCellStyle headerStyle = workbook.createCellStyle();
// 设置这些样式
headerStyle.setFillForegroundColor(headerCellBackgroundColor);
headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerStyle.setBorderBottom(headerBorderBottom);
headerStyle.setBorderLeft(headerBorderLeft);
headerStyle.setBorderRight(headerBorderRight);
headerStyle.setBorderTop(headerBorderTop);
headerStyle.setAlignment(headerCellTextAlign);
headerStyle.setVerticalAlignment(headerCellVehicleAlign);
// 生成字体
HSSFFont font = workbook.createFont();
font.setColor(headerFontColor);
font.setFontHeightInPoints(headerFontHeight);
font.setBoldweight(headerFontWeight);
// 把字体应用到当前的样式
headerStyle.setFont(font);
return headerStyle;
}
示例14: createHeaderStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public HSSFCellStyle createHeaderStyle() {
HSSFCellStyle style = workbook.createCellStyle();
final HSSFFont font = workbook.createFont();
font.setBold(true);
style.setFont(font);
style.setBorderBottom(BorderStyle.THIN);
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setAlignment(HorizontalAlignment.CENTER);
style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.PALE_BLUE.getIndex());
return style;
}
示例15: createTitleStyle
import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public HSSFCellStyle createTitleStyle() {
HSSFCellStyle style = workbook.createCellStyle();
final HSSFFont font = workbook.createFont();
font.setBold(true);
style.setFont(font);
style.setBorderBottom(BorderStyle.THICK);
style.setVerticalAlignment(VerticalAlignment.CENTER);
return style;
}