当前位置: 首页>>代码示例>>Java>>正文


Java Workbook.createCellStyle方法代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Workbook.createCellStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Workbook.createCellStyle方法的具体用法?Java Workbook.createCellStyle怎么用?Java Workbook.createCellStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.ss.usermodel.Workbook的用法示例。


在下文中一共展示了Workbook.createCellStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: defaultDataCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
/**
 * Returns the default data cell 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 defaultDataCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setWrapText(true);
    style.setBorderRight(BorderStyle.THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(BorderStyle.THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(BorderStyle.THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setDataFormat(doubleDataFormat);
    return style;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:25,代码来源:ExcelExport.java

示例2: defaultHeaderCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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: doCreateCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
/** 创建每个CellStyle,并放到map之中
 * @param workbook
 * @param styleInfo
 * @param dataFormat 
 * @return
 */
public static CellStyle doCreateCellStyle(Workbook workbook,ExportCellStyleInfo styleInfo,String dataFormat) {
	if(styleInfo != null ){
		CellStyle cellStyle = workbook.createCellStyle();
		setStyleValue(ExportCellStyleInfo.class, cellStyle, styleInfo);
		if(styleInfo.getFontStyleInfo() != null){
			Font fontStyle = workbook.createFont();
			setStyleValue(ExportFontStyleInfo.class, fontStyle, styleInfo.getFontStyleInfo());
			cellStyle.setFont(fontStyle);
		}
		if(!StringUtils.isEmpty(dataFormat)){
			short format = workbook.createDataFormat().getFormat(dataFormat);
			cellStyle.setDataFormat(format);
		}
		return cellStyle;
	}
	return null;
}
 
开发者ID:long47964,项目名称:excel-utils,代码行数:24,代码来源:CellStyleUtils.java

示例4: defaultTitleCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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

示例5: createStyles

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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

示例6: createBorderedStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private static CellStyle createBorderedStyle(Workbook wb) {
    CellStyle style = wb.createCellStyle();
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    return style;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:13,代码来源:Exporter.java

示例7: createStyles

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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

示例8: createBorderCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
public CellStyle createBorderCellStyle(Workbook workbook, boolean showBorder) {
	CellStyle style = workbook.createCellStyle();
	if (showBorder) {
		style.setBorderRight(BorderStyle.THIN);
		style.setRightBorderColor(IndexedColors.BLACK.getIndex());
		style.setBorderBottom(BorderStyle.THIN);
		style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
		style.setBorderLeft(BorderStyle.THIN);
		style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
		style.setBorderTop(BorderStyle.THIN);
		style.setTopBorderColor(IndexedColors.BLACK.getIndex());
	}
	return style;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:AbstractStyleBuilder.java

示例9: createCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private static XSSFCellStyle createCellStyle(Workbook workbook) {
    XSSFCellStyle xstyle = (XSSFCellStyle) workbook.createCellStyle();
    XSSFFont font = (XSSFFont) workbook.createFont();
    font.setFontHeightInPoints((short) 11);
    xstyle.setFont(font);
    return xstyle;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:aem-epic-tool,代码行数:8,代码来源:ReportUtil.java

示例10: initialize

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@Override
public void initialize(Workbook workbook) {
	this.borderStyle = workbook.createCellStyle();
	this.borderStyle.setBorderBottom(BorderStyle.THIN);
	this.borderStyle.setBorderTop(BorderStyle.THIN);
	this.borderStyle.setBorderRight(BorderStyle.THIN);
	this.borderStyle.setBorderLeft(BorderStyle.THIN);
}
 
开发者ID:Coreoz,项目名称:Windmill,代码行数:9,代码来源:ExcelCellStyler.java

示例11: initializeSheet

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private static CellStyle initializeSheet(Workbook wb, Sheet sheet) {
    PrintSetup printSetup = sheet.getPrintSetup();
    printSetup.setLandscape(true);
    sheet.setFitToPage(true);
    sheet.setHorizontallyCenter(true);

    CellStyle styleTitle;
    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 12);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    titleFont.setFontName("Arial");
    styleTitle = wb.createCellStyle();
    styleTitle.setFont(titleFont);
    return styleTitle;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:ExcelHandler.java

示例12: createDateStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private CellStyle createDateStyle(Workbook workbook) {
    CellStyle style = workbook.createCellStyle();
    style.setDataFormat(workbook.getCreationHelper().createDataFormat()
            .getFormat("m/d/yy"));

    return style;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:8,代码来源:Exporter.java

示例13: defaultTotalsDoubleCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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

示例14: defaultTotalsIntegerCellStyle

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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

示例15: createCell

import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的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


注:本文中的org.apache.poi.ss.usermodel.Workbook.createCellStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。