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


Java HSSFCellStyle.setWrapText方法代码示例

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


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

示例1: 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();
	}
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:25,代码来源:ExcelExportSuper.java

示例2: createCellStyleForColumnHeading

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static HSSFCellStyle createCellStyleForColumnHeading(HSSFWorkbook workBook) {
	HSSFCellStyle cellStyle = workBook.createCellStyle();
	HSSFFont fontObj = workBook.createFont();
	cellStyle.setBorderBottom(BorderStyle.THIN);
	cellStyle.setBorderTop(BorderStyle.THIN);
	cellStyle.setBorderLeft(BorderStyle.THIN);
	cellStyle.setBorderRight(BorderStyle.THIN);
	cellStyle.setWrapText(true);
	cellStyle.setAlignment(HorizontalAlignment.CENTER);
	cellStyle.setFillBackgroundColor(Short.valueOf("22").shortValue());
	cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
	cellStyle.setFillForegroundColor(Short.valueOf("22").shortValue());
	cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
	fontObj.setFontName("Calibri");
	fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
	fontObj.setBold(true);
	fontObj.setColor(Short.valueOf("8").shortValue());
	cellStyle.setFont(fontObj);
	return cellStyle;
}
 
开发者ID:siteadmin,项目名称:CCDA-Score-CARD,代码行数:21,代码来源:ScorecardExcelGenerator.java

示例3: getHeaderStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private HSSFCellStyle getHeaderStyle(final int col)
{
	String key = "header-" + col;
	HSSFCellStyle cs_header = m_styles.get(key);
	if (cs_header == null)
	{
		HSSFFont font_header = getFont(true);
		cs_header = m_workbook.createCellStyle();
		cs_header.setFont(font_header);
		cs_header.setBorderLeft((short)2);
		cs_header.setBorderTop((short)2);
		cs_header.setBorderRight((short)2);
		cs_header.setBorderBottom((short)2);
		cs_header.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
		cs_header.setWrapText(true);
		m_styles.put(key, cs_header);
	}
	return cs_header;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:20,代码来源:AbstractExcelExporter.java

示例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;
}
 
开发者ID:wallellen,项目名称:wl,代码行数:17,代码来源:ExcelExcuter.java

示例5: 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;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-commons,代码行数:19,代码来源:ExcelStyle.java

示例6: 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;
    }
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:30,代码来源:POIUtils.java

示例7: 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;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:31,代码来源:POIUtils.java

示例8: 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;
}
 
开发者ID:wallellen,项目名称:wl,代码行数:12,代码来源:ExcelExcuter.java

示例9: 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;
}
 
开发者ID:wallellen,项目名称:wl,代码行数:12,代码来源:ExcelExcuter.java

示例10: 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;
}
 
开发者ID:wallellen,项目名称:wl,代码行数:14,代码来源:ExcelExcuter.java

示例11: initCellStyles

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
 * We cache the styles; they are expensive to construct.
 * @param properties props for this run
 */
public void initCellStyles(TableProperties properties)
{
    // Integer
    HSSFCellStyle style = getNewCellStyle();
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_INTEGER)));
    cellStyles.put(STYLE_INTEGER, style);

    // NUMBER
    style = getNewCellStyle();
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_NUMBER)));
    cellStyles.put(STYLE_NUMBER, style);

    // style = HSSFDataFormat.getBuiltinFormat("0.00%");

    // Date
    style = getNewCellStyle();
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_DATE)));
    style.setAlignment(CellStyle.ALIGN_RIGHT);
    cellStyles.put(STYLE_DATE, style);

    // Long text
    style = getNewCellStyle(); // http://jakarta.apache.org/poi/hssf/quick-guide.html#NewLinesInCells
    style.setWrapText(true);
    cellStyles.put(STYLE_LONGSTRING, style);

    // Regular text
    cellStyles.put(STYLE_STRING, getNewCellStyle());

    wrapAt = Integer.valueOf(properties.getProperty(ExcelUtils.EXCEL_WRAPAT));
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:38,代码来源:ExcelUtils.java

示例12: setValueStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private void setValueStyle(HSSFWorkbook wb) {
    HSSFCellStyle style = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setColor(HSSFColor.BLACK.index);
    font.setFontHeightInPoints((short) 8);
    style.setFont(font);
    style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
    style.setWrapText(true);
    valueStyle = style;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-commons,代码行数:11,代码来源:ExcelStyle.java

示例13: setRedValueStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
private void setRedValueStyle(HSSFWorkbook wb) {
    HSSFCellStyle style = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setColor(HSSFColor.RED.index);
    font.setFontHeightInPoints((short) 8);
    style.setFont(font);
    style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
    style.setWrapText(true);
    redValueStyle = style;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-commons,代码行数:11,代码来源:ExcelStyle.java

示例14: exportMotionExcel

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
 * 为退款经办下载表
 * 
 * @param outfile
 * @param list
 * @param name
 *            表名
 * @param s为每一格的宽度
 * @throws IOException
 */
public FileTransfer exportMotionExcel(List<String[]> list, String filename,
		String name, String[] s) throws Exception {

	ByteArrayOutputStream buffer = new ByteArrayOutputStream();
	HSSFWorkbook wb = new HSSFWorkbook();
	HSSFSheet sheet = wb.createSheet();
	HSSFCellStyle cs = wb.createCellStyle();
	// 设置表头的格式
	HSSFCellStyle cs1 = wb.createCellStyle();
	HSSFFont f1 = wb.createFont();
	f1.setFontHeightInPoints((short) 20);// 字体大小
	cs1.setFont(f1);
	cs1.setAlignment(HSSFCellStyle.ALIGN_CENTER);

	// 设置表中的格�?
	cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
	cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
	cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	cs.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
	cs.setWrapText(true);// 自动换行
	// 将页面设�为横向打印模�?
	HSSFPrintSetup hps = sheet.getPrintSetup();
	hps.setLandscape(true); // 将页面设置为横向打印模式
	hps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);// 为A4纸的大小

	int columnCount = list.get(0).length;
	// 表头那一列的的宽�?
	sheet.setColumnWidth((short) 0, (short) 10000);
	// 合并单元�?
	// sheet.addMergedRegion(new Region((short) 0, (short) 0, (short) 0,
	// (short) (columnCount-1)));
	// 根据String[] s来设定每一格的宽度
	for (int i = 0; i < columnCount; i++) {
		sheet.setColumnWidth((short) i, (Short.parseShort(s[i])));
	}
	// 表名
	HSSFRow row1 = sheet.createRow(0);
	HSSFCell cell = row1.createCell(0);
	cell.setCellValue(name);
	cell.setCellStyle(cs1);
	row1.setHeight((short) 800);
	sheet.addMergedRegion(new Region((short) 0, (short) 0, (short) 0,
			(short) (columnCount - 1)));

	HSSFRow rows = null;
	for (int i = 0; i < list.size(); i++) {
		rows = sheet.createRow(i + 1);
		String cellDate[] = list.get(i);
		HSSFCell cells = null;
		for (int j = 0; j < cellDate.length; j++) {
			cells = rows.createCell((short) (j));
			cells.setCellValue(cellDate[j]);
			cells.setCellStyle(cs);
		}
		if (i == 0) {
			rows.setHeight((short) 600);// 标题行宽�?
		}
	}
	wb.write(buffer);
	return new FileTransfer(filename, "application/x-xls", buffer
			.toByteArray());
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:75,代码来源:DownloadFileService.java

示例15: createCellStyleForRows

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static HSSFCellStyle createCellStyleForRows(HSSFWorkbook workBook) {
	HSSFCellStyle cellStyle = workBook.createCellStyle();
	cellStyle.setWrapText(true);
	cellStyle.setAlignment(HorizontalAlignment.CENTER);
	return cellStyle;
}
 
开发者ID:siteadmin,项目名称:CCDA-Score-CARD,代码行数:7,代码来源:ScorecardExcelGenerator.java


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