本文整理了Java中org.apache.poi.ss.usermodel.Row.setHeightInPoints
方法的一些代码示例,展示了Row.setHeightInPoints
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Row.setHeightInPoints
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Row
类名称:Row
方法名:setHeightInPoints
[英]Set the row's height in points.
[中]以点为单位设置行的高度。
代码示例来源:origin: looly/hutool
/**
* 设置行高,值为一个点的高度
*
* @param rownum 行号(从0开始计数,-1表示所有行的默认高度)
* @param height 高度
* @return this
* @since 4.0.8
*/
public ExcelWriter setRowHeight(int rownum, int height) {
if (rownum < 0) {
this.sheet.setDefaultRowHeightInPoints(height);
} else {
this.sheet.getRow(rownum).setHeightInPoints(height);
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 设置行高,值为一个点的高度
*
* @param rownum 行号(从0开始计数,-1表示所有行的默认高度)
* @param height 高度
* @return this
* @since 4.0.8
*/
public ExcelWriter setRowHeight(int rownum, int height) {
if (rownum < 0) {
this.sheet.setDefaultRowHeightInPoints(height);
} else {
this.sheet.getRow(rownum).setHeightInPoints(height);
}
return this;
}
代码示例来源:origin: stackoverflow.com
Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(2);
Cell cell = row.createCell(2);
cell.setCellValue("Use \n with word wrap on to create a new line");
//to enable newlines you need set a cell styles with wrap=true
CellStyle cs = wb.createCellStyle();
cs.setWrapText(true);
cell.setCellStyle(cs);
//increase row height to accomodate two lines of text
row.setHeightInPoints((2*sheet.getDefaultRowHeightInPoints()));
//adjust column width to fit the content
sheet.autoSizeColumn((short)2);
FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx");
wb.write(fileOut);
fileOut.close();
代码示例来源:origin: Vatavuk/excel-io
@Override
public void accept(final Row row) {
row.setHeightInPoints(this.value);
}
}
代码示例来源:origin: org.apache.solr/solr-cell
void setHeaderRow() {
curRow.setHeightInPoints((short)21);
}
代码示例来源:origin: cn.hutool/hutool-all
/**
* 设置行高,值为一个点的高度
*
* @param rownum 行号(从0开始计数,-1表示所有行的默认高度)
* @param height 高度
* @return this
* @since 4.0.8
*/
public ExcelWriter setRowHeight(int rownum, int height) {
if (rownum < 0) {
this.sheet.setDefaultRowHeightInPoints(height);
} else {
this.sheet.getRow(rownum).setHeightInPoints(height);
}
return this;
}
代码示例来源:origin: org.hswebframework/hsweb-expands-office
protected void initRow(Row row, int index, String header) {
CustomRowStyle rowStyle = config.getRowStyle(index, header);
if (rowStyle != null) {
row.setHeightInPoints((float) rowStyle.getHeight());
}
}
代码示例来源:origin: hs-web/hsweb-expands
protected void initRow(Row row, int index, String header) {
CustomRowStyle rowStyle = config.getRowStyle(index, header);
if (rowStyle != null) {
row.setHeightInPoints((float) rowStyle.getHeight());
}
}
代码示例来源:origin: zsl131/spring-boot-test
/**
* 创建新行,在使用时只要添加完一行,需要调用该方法创建
*/
public void createNewRow() {
if(lastRowIndex>curRowIndex&&curRowIndex!=initRowIndex) {
sheet.shiftRows(curRowIndex, lastRowIndex, 1,true,true);
lastRowIndex++;
}
curRow = sheet.createRow(curRowIndex);
curRow.setHeightInPoints(rowHeight);
curRowIndex++;
curColIndex = initColIndex;
}
代码示例来源:origin: subtlelib/poi
/**
* Define row height as follows:
* - row height set explicitly by user: value defined by user;
* - multiline output and no row height defined: default height * number of lines;
* - otherwise: auto row height (by setting height to a magic value of #ROW_HEIGHT_AUTOMATIC);
*/
private void assignRowHeight(int rowHeightMultiplier) {
if (rowHeightMultiplier > 1 && rowHeight == ROW_HEIGHT_AUTOMATIC) {
row.setHeightInPoints(row.getHeightInPoints() * rowHeightMultiplier);
} else {
row.setHeight(rowHeight);
}
}
代码示例来源:origin: biezhi/excel-plus
private void writeHeader(CellStyle cellStyle, Sheet sheet, String title, int maxColIndex) {
Row titleRow = sheet.createRow(0);
titleRow.setHeightInPoints(50);
for (int i = 0; i <= maxColIndex; i++) {
Cell cell = titleRow.createCell(i);
if (i == 0) {
cell.setCellValue(title);
}
cell.setCellStyle(cellStyle);
}
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, maxColIndex));
}
代码示例来源:origin: cn.bestwu.simpleframework/simpleframework-web
/**
* @param title 标题
* @param titleStyle 标题样式
*/
public void createTitle(String title, CellStyle titleStyle) {
Assert.hasText(title, "title不能为空");
Row titleRow = sheet.createRow(rownum++);
titleRow.setHeightInPoints(30);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellStyle(titleStyle);
titleCell.setCellValue(title);
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
titleRow.getRowNum(), 0, excelFieldDescriptions.size() - 1));
}
代码示例来源:origin: lcw2004/one
/**
* 初始化标题
* @param maxColNumber 最大列数
*/
protected void initTitle(int maxColNumber) {
int rowNum = this.currentRowNum++;
Row titleRow = POIUtils.createRow(sheet, rowNum);
titleRow.setHeightInPoints(30);
// 合并单元格
POIUtils.mergeCellRangeInRow(sheet, excelStyle.getTitleStyle(), rowNum, 0, maxColNumber);
Cell cell = titleRow.getCell(0);
cell.setCellValue(title);
cell.setCellStyle(excelStyle.getTitleStyle());
}
代码示例来源:origin: lcw2004/one
/**
* 初始化Excel标题
*
*/
protected void initHead(int currentRowNum) {
Row headerRow = sheet.createRow(currentRowNum);
headerRow.setHeightInPoints(25);
for (ExcelFieldRule excelFieldRule : excelClassRule.getFieldRuleList()) {
Cell cell = headerRow.createCell(excelFieldRule.getIndex());
cell.setCellValue(excelFieldRule.getTitle());
cell.setCellStyle(excelStyle.getHeaderStyle());
}
}
代码示例来源:origin: bedatadriven/activityinfo
private void writeHeaders(HSSFSheet sheet, String title, List<XlsColumn> columns) {
Cell titleCell = sheet.createRow(0).createCell(0);
titleCell.setCellValue(book.getCreationHelper().createRichTextString(title));
titleCell.setCellStyle(titleStyle);
Row columnHeaderRow = sheet.createRow(1);
columnHeaderRow.setHeightInPoints(HEADER_CELL_HEIGHT);
int columnIndex = 0;
for (int i = 0; i < columns.size(); i++) {
XlsColumn column = columns.get(i);
Cell cell = columnHeaderRow.createCell(columnIndex);
cell.setCellStyle(headerStyle);
cell.setCellValue(column.getHeading());
sheet.setColumnWidth(columnIndex, width(column.getHeading()));
columnIndex++;
}
}
代码示例来源:origin: hyberbin/J-Excel
/**
* 初始化单元格
*/
private void ini(){
log.debug("初始化单元格总共:{}行,{}列",tableBean.getRowCount(),tableBean.getColumnCount());
for(int r=0;r<tableBean.getRowCount();r++){
Row row = sheet.createRow(r);
if(tableBean.getRowHeight()!=null){
row.setHeightInPoints(tableBean.getRowHeight());
}
for(int c=0;c<tableBean.getColumnCount();c++){
row.createCell(c);
}
}
}
代码示例来源:origin: cyuanxin/excel_export_import
private static void createTitleRow(Workbook workbook, Row row, List<ExportCell> exportCells, Sheet sheet) {
CellStyle style = createHeadStyle(workbook);
row.setHeightInPoints(25.0F);
Font font = workbook.createFont();
font.setColor((short) 12);
// font.setBoldweight((short) 700);
style.setFont(font);
style.setFillBackgroundColor((short) 13);
int i = 0;
for (ExportCell exportCell : exportCells) {
sheet.setColumnWidth(i, 3200);
Cell cell = row.createCell(i);
cell.setCellValue(exportCell.getTitle());
cell.setCellStyle(style);
++i;
}
}
代码示例来源:origin: biezhi/excel-plus
private void writeColumnNames(int rowIndex, CellStyle headerStyle) {
Row rowHead = sheet.createRow(rowIndex);
rowHead.setHeightInPoints(30);
for (ExcelColumn column : columns) {
Cell cell = rowHead.createCell(column.index());
if (null != headerStyle) {
cell.setCellStyle(headerStyle);
}
cell.setCellValue(column.title());
if (column.width() > 0) {
sheet.setColumnWidth(column.index(), column.width());
} else {
sheet.setColumnWidth(column.index(), Constant.DEFAULT_COLUMN_WIDTH);
}
}
}
代码示例来源:origin: org.hswebframework/hsweb-expands-office
@Override
public void nextRow(Cell cell) {
if (nowRow == null) {
//首次渲染行,则将表达式所在行替换为数据行
nowRow = cell.getRow();
} else {
//创建下一行
int rowNum = nowRow.getRowNum() + 1;
//将最后一行移动到当前行,以实现插入行效果
sheet.shiftRows(rowNum,sheet.getLastRowNum(),1,true,false);
Row tmp = sheet.createRow(rowNum);
tmp.setHeight(nowRow.getHeight());
tmp.setHeightInPoints(nowRow.getHeightInPoints());
nowRow = tmp;
}
}
代码示例来源:origin: hs-web/hsweb-expands
@Override
public void nextRow(Cell cell) {
if (nowRow == null) {
//首次渲染行,则将表达式所在行替换为数据行
nowRow = cell.getRow();
} else {
//创建下一行
int rowNum = nowRow.getRowNum() + 1;
//将最后一行移动到当前行,以实现插入行效果
sheet.shiftRows(rowNum,sheet.getLastRowNum(),1,true,false);
Row tmp = sheet.createRow(rowNum);
tmp.setHeight(nowRow.getHeight());
tmp.setHeightInPoints(nowRow.getHeightInPoints());
nowRow = tmp;
}
}
内容来源于网络,如有侵权,请联系作者删除!