當前位置: 首頁>>代碼示例>>Java>>正文


Java CellStyle.setVerticalAlignment方法代碼示例

本文整理匯總了Java中org.apache.poi.ss.usermodel.CellStyle.setVerticalAlignment方法的典型用法代碼示例。如果您正苦於以下問題:Java CellStyle.setVerticalAlignment方法的具體用法?Java CellStyle.setVerticalAlignment怎麽用?Java CellStyle.setVerticalAlignment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.ss.usermodel.CellStyle的用法示例。


在下文中一共展示了CellStyle.setVerticalAlignment方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIndentationCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
public CellStyle createIndentationCellStyle(Workbook workbook, int s) {
	CellStyle dataStyle1 = this.createBorderCellStyle(workbook, true);
	Font dataFont = workbook.createFont();
	dataFont.setColor((short) 12);
	dataFont.setFontHeightInPoints((short) 10);
	dataStyle1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
	dataStyle1.setFillForegroundColor((short) 11);
	dataStyle1.setFont(dataFont);
	dataStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
	dataStyle1.setAlignment(HorizontalAlignment.LEFT);
	dataStyle1.setIndention(Short.valueOf(String.valueOf((s))));
	return dataStyle1;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:14,代碼來源:GridStyleBuilder.java

示例2: defaultHeaderCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * Returns the default header style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultHeaderCellStyle(final Workbook wb) {
    CellStyle style;
    final Font monthFont = wb.createFont();
    monthFont.setFontHeightInPoints((short) 11);
    monthFont.setColor(IndexedColors.WHITE.getIndex());
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(monthFont);
    style.setWrapText(true);
    return style;
}
 
開發者ID:TFyre,項目名稱:vaadin-gridexport,代碼行數:23,代碼來源:ExcelExport.java

示例3: defaultTitleCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * Returns the default title style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTitleCellStyle(final Workbook wb) {
    CellStyle style;
    final Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 18);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFont(titleFont);
    return style;
}
 
開發者ID:TFyre,項目名稱:vaadin-gridexport,代碼行數:20,代碼來源:ExcelExport.java

示例4: createStyles

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
     * 創建表格樣式
     * @param wb 工作薄對象
     * @return 樣式列表
     */
    private Map<String, CellStyle> createStyles(Workbook wb) {
        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

        CellStyle style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        Font titleFont = wb.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short) 16);
        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        style.setFont(titleFont);
        styles.put("title", style);

        style = wb.createCellStyle();
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        Font dataFont = wb.createFont();
        dataFont.setFontName("Arial");
        dataFont.setFontHeightInPoints((short) 10);
        style.setFont(dataFont);
        styles.put("data", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_LEFT);
        styles.put("data1", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_CENTER);
        styles.put("data2", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        styles.put("data3", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
//		style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        Font headerFont = wb.createFont();
        headerFont.setFontName("Arial");
        headerFont.setFontHeightInPoints((short) 10);
        headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        headerFont.setColor(IndexedColors.WHITE.getIndex());
        style.setFont(headerFont);
        styles.put("header", style);

        return styles;
    }
 
開發者ID:sombie007,項目名稱:ExcelHandle,代碼行數:66,代碼來源:ExportExcel.java

示例5: createStyles

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * excel 樣式
 *
 * @return
 */
public Map<String, CellStyle> createStyles(Workbook workbook) {
    Map<String, CellStyle> styles = new HashMap();
    CellStyle style = workbook.createCellStyle();
    style.setAlignment((short) 2);
    style.setVerticalAlignment((short) 1);
    Font titleFont = workbook.createFont();
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 16);
    titleFont.setBoldweight((short) 700);
    style.setFont(titleFont);
    styles.put("title", style);
    style = workbook.createCellStyle();
    style.setVerticalAlignment((short) 1);
    style.setBorderRight((short) 1);
    style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderLeft((short) 1);
    style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderTop((short) 1);
    style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderBottom((short) 1);
    style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    Font dataFont = workbook.createFont();
    dataFont.setFontName("Arial");
    dataFont.setFontHeightInPoints((short) 10);
    style.setFont(dataFont);
    styles.put("data", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 1);
    styles.put("data1", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 2);
    styles.put("data2", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 3);
    styles.put("data3", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 2);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern((short) 1);
    Font headerFont = workbook.createFont();
    headerFont.setFontName("Arial");
    headerFont.setFontHeightInPoints((short) 10);
    headerFont.setBoldweight((short) 700);
    headerFont.setColor(IndexedColors.WHITE.getIndex());
    style.setFont(headerFont);
    styles.put("header", style);
    return styles;
}
 
開發者ID:zhangbiy,項目名稱:exportExcel,代碼行數:58,代碼來源:ExcelTest.java

示例6: setCommonStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * 設置通用的對齊居中、邊框等
 *
 * @param style 樣式
 */
private void setCommonStyle(CellStyle style) {
    // 設置單元格居中對齊、自動換行
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setWrapText(true);

    //設置單元格字體
    if (!buildInFontMap.containsKey(FONT_KEY)) {
        Font font = workbook.createFont();
        //通用字體
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        font.setFontName("宋體");
        font.setFontHeight((short) 200);
        buildInFontMap.put(FONT_KEY, font);
    }
    style.setFont(buildInFontMap.get(FONT_KEY));

    // 設置單元格邊框為細線條
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_THIN);
}
 
開發者ID:goribun,項目名稱:excel-rw-annotation,代碼行數:29,代碼來源:StyleConfiguration.java

示例7: builderValueCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
public CellStyle builderValueCellStyle(ReportForm reportFormModel, Workbook workbook) {
	List<ReportFormData> list = reportFormModel.getListReportFormDataModel();
	ReportFormData reportFormDataModel;
	if (list.size() > 0) {
		reportFormDataModel = list.get(0);
		int dataAlign = reportFormDataModel.getDataAlign();
		int dataStyle = reportFormDataModel.getDataStyle();
		CellStyle valueStyle = createBorderCellStyle(workbook, reportFormModel.isShowBorder());
		setCellStyleAligment(valueStyle, dataAlign);
		valueStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		this.setCellStyleFont(workbook, valueStyle, dataStyle);
		return valueStyle;
	}
	return null;

}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:17,代碼來源:FormStyleBuilder.java

示例8: createSheet

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * Creates an excel sheet in the provided workbook using provided parameters.
 * 
 * @param input the data to put in the sheet-
 * @param sheetName the name to user for the sheet.
 * @param wb the workbook to create the sheet in.
 */
private void createSheet(	List<MessageResourceEntry> input,
							String sheetName,
							Workbook wb)
{
	// create a new sheet
	String name = StringUtils.isBlank(sheetName) ? this.defaultSheetName : sheetName;
	LOG.info("Create sheet with name " + name);
	Sheet sheet = wb.createSheet(name);
	sheet.setZoom(this.zoom, 100);

	Map<Locale, Integer> langs = getLanguageInformation(input);
	createHeader(sheet, langs);

	CellStyle keyStyle = sheet.getWorkbook().createCellStyle();
	keyStyle.setAlignment(CellStyle.ALIGN_LEFT);
	keyStyle.setBorderBottom(CellStyle.BORDER_THIN);
	keyStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
	Font f = sheet.getWorkbook().createFont();
	f.setBoldweight(Font.BOLDWEIGHT_NORMAL);
	keyStyle.setFont(f);

	CellStyle valueStyle = sheet.getWorkbook().createCellStyle();
	valueStyle.setAlignment(CellStyle.ALIGN_LEFT);
	valueStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
	valueStyle.setBorderBottom(CellStyle.BORDER_THIN);
	valueStyle.setBorderRight(CellStyle.BORDER_THIN);
	valueStyle.setBorderTop(CellStyle.BORDER_THIN);
	valueStyle.setBorderLeft(CellStyle.BORDER_THIN);
	valueStyle.setFont(f);
	valueStyle.setWrapText(true);

	CellStyle emptyStyle = sheet.getWorkbook().createCellStyle();
	emptyStyle.setAlignment(CellStyle.ALIGN_LEFT);
	emptyStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
	emptyStyle.setBorderBottom(CellStyle.BORDER_THIN);
	emptyStyle.setBorderRight(CellStyle.BORDER_THIN);
	emptyStyle.setBorderTop(CellStyle.BORDER_THIN);
	emptyStyle.setBorderLeft(CellStyle.BORDER_THIN);
	emptyStyle.setFont(f);
	emptyStyle.setFillForegroundColor(IndexedColors.LAVENDER.getIndex());
	emptyStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
	emptyStyle.setWrapText(true);

	LOG.info("Write data to sheet " + name);
	int rowIndex = this.languageHeaderRow + 1;
	for (MessageResourceEntry entry : input)
	{
		Row row = sheet.createRow(rowIndex);
		createContentRow(entry, row, langs, keyStyle, valueStyle, emptyStyle);
		rowIndex++;
	}
	sizeColumns(sheet, langs);
	sheet.createFreezePane(this.firstLanguageColumn, this.languageHeaderRow + 1, this.firstLanguageColumn, this.languageHeaderRow + 1);
}
 
開發者ID:namics,項目名稱:spring-i18n-support,代碼行數:62,代碼來源:ExcelWriter.java

示例9: defaultTotalsDoubleCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * Returns the default totals row style for Double data. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTotalsDoubleCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setDataFormat(doubleDataFormat);
    return style;
}
 
開發者ID:TFyre,項目名稱:vaadin-gridexport,代碼行數:19,代碼來源:ExcelExport.java

示例10: defaultTotalsIntegerCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * Returns the default totals row style for Integer data. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTotalsIntegerCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setDataFormat(integerDataFormat);
    return style;
}
 
開發者ID:TFyre,項目名稱:vaadin-gridexport,代碼行數:19,代碼來源:ExcelExport.java

示例11: createCell

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
/**
 * Creates a cell and aligns it a certain way.
 *
 * @param wb     the workbook
 * @param row    the row to create the cell in
 * @param column the column number to create the cell in
 * @param halign the horizontal alignment for the cell.
 */
private static void createCell(Workbook wb, Row row, short column, short halign, short valign) {
    Cell cell = row.createCell(column);
    cell.setCellValue("Align It");
    CellStyle cellStyle = wb.createCellStyle();
    cellStyle.setAlignment(halign);
    cellStyle.setVerticalAlignment(valign);
    cell.setCellStyle(cellStyle);
}
 
開發者ID:robinhowlett,項目名稱:handycapper,代碼行數:17,代碼來源:PDFtoXLSX.java

示例12: builderLabelCellStyle

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
public CellStyle builderLabelCellStyle(ReportForm reportFormModel, Workbook workbook) {
	List<ReportFormData> list = reportFormModel.getListReportFormDataModel();
	ReportFormData reportFormDataModel;
	if (list.size() > 0) {
		reportFormDataModel = list.get(0);
		int labelAlign = reportFormDataModel.getLabelAlign();
		CellStyle labelStyle = createBorderCellStyle(workbook, reportFormModel.isShowBorder());
		setCellStyleAligment(labelStyle, labelAlign);
		labelStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		return labelStyle;
	}
	return null;

}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:15,代碼來源:FormStyleBuilder.java

示例13: test4

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的package包/類
@Test
public void test4() throws Exception {
    List<String> excludeProps = new ArrayList<>();
    excludeProps.add("Price");
    XLSXWriter<Map<String, Object>> xlsxWriter =
            new XLSXWriter<>(new File("C:\\Users\\FlyingHe\\Desktop", "datas1.xlsx"),
                    101, null, true, excludeProps, null, true, null, false);
    Font font1 = xlsxWriter.createFont();
    CellStyle dataCellStyle = xlsxWriter.createCellStyle();
    dataCellStyle.setFont(font1);
    dataCellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    dataCellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    xlsxWriter.setDefaultCellStyle(dataCellStyle);

    List<Map<String, Object>> list = new ArrayList<>();
    long s = System.currentTimeMillis();
    System.out.println("================Start================");
    for (int i = 0; i < 1000; i++) {
        Map<String, Object> student = new HashMap<>();
        if ((i + 1) % 51 != 0) {
            student.put("name", "name:" + i);
            student.put("_byte", (byte) (i % 127));
            student.put("_short", (short) (i % 32767));
            student.put("age", i);
            student.put("Price", i + 0.99F);
            student.put("Prices", i + 1.99D);
            student.put("date", new Date(new Date().getTime() + i * 24 * 3600000L));
            if ((i + 1) % 30 != 0) {
                student.put("Email", "Email:" + i);
                student.put("Tel", "Tel:" + i);
            }

        }
        list.add(student);
        if ((i + 1) % 100 == 0) {
            xlsxWriter.setDefaultCellStyle(dataCellStyle);
            xlsxWriter.write(list);
            list.clear();
            System.out.println("已經寫入數據量:" + xlsxWriter.getRealRowInExcel());
        }
    }
    xlsxWriter.endWrite();
    System.out.println("================Done================");
    long e = System.currentTimeMillis();
    System.out.println("一共寫入數據量:" + xlsxWriter.getRealRowInExcel());
    System.out.println("Sheet數:" + (xlsxWriter.getAllSheetInExcel()));
    System.out.println("一共耗時:" + (e - s) + "ms");
}
 
開發者ID:FlyingHe,項目名稱:UtilsMaven,代碼行數:49,代碼來源:TestExcelUtils.java

示例14: createHSSFCellStyles

import org.apache.poi.ss.usermodel.CellStyle; //導入方法依賴的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;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:72,代碼來源:GridStyleBuilder.java


注:本文中的org.apache.poi.ss.usermodel.CellStyle.setVerticalAlignment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。