本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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: 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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}