org.apache.poi.ss.usermodel.Sheet.getDefaultRowHeight()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.apache.poi.ss.usermodel.Sheet.getDefaultRowHeight()方法的一些代码示例,展示了Sheet.getDefaultRowHeight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sheet.getDefaultRowHeight()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Sheet
类名称:Sheet
方法名:getDefaultRowHeight

Sheet.getDefaultRowHeight介绍

[英]Get the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
[中]获取图纸的默认行高(如果行未定义自己的高度),单位为twips(1/20点)

代码示例

代码示例来源:origin: stackoverflow.com

Workbook wb = new HSSFWorkbook();
 FileOutputStream fileOut = new FileOutputStream("workbook.xls");
 CreationHelper createHelper = wb.getCreationHelper();
 Sheet sheet = wb.createSheet("new sheet");
 Row row = sheet.createRow((short) 0);
 row.setHeight((short) (2*sheet.getDefaultRowHeight()));
 CellStyle cs = wb.createCellStyle();
 cs.setWrapText(true);
 Cell cell = row.createCell(0);
 cell.setCellStyle(cs);
 cell.setCellValue(
 createHelper.createRichTextString("This is \n a string"));
 wb.write(fileOut);
 fileOut.close();

代码示例来源:origin: org.jxls/jxls-poi

@Override
  public void updateRowHeight(String srcSheetName, int srcRowNum, String targetSheetName, int targetRowNum) {
    if (isSXSSF) return;
    SheetData sheetData = sheetMap.get(srcSheetName);
    RowData rowData = sheetData.getRowData(srcRowNum);
    Sheet sheet = workbook.getSheet(targetSheetName);
    if (sheet == null) {
      sheet = workbook.createSheet(targetSheetName);
    }
    Row targetRow = sheet.getRow(targetRowNum);
    if (targetRow == null) {
      targetRow = sheet.createRow(targetRowNum);
    }
    short srcHeight = rowData != null ? (short) rowData.getHeight() : sheet.getDefaultRowHeight();
    targetRow.setHeight(srcHeight);
  }
}

代码示例来源:origin: spdx/tools

/**
 * resize the rows for a best fit.  Will not exceed maximum row height.
 */
public void resizeRows() {
  // header row
  // data rows
  int lastRow = this.getNumDataRows()+this.getFirstDataRow()-1;
  for (int i = 0; i <= lastRow; i++) {
    Row row = sheet.getRow(i);
    int lastCell = row.getLastCellNum();	// last cell + 1
    int maxNumLines = 1;
    for (int j = 0; j < lastCell; j++) {
      Cell cell = row.getCell(j);
      if (cell != null) {
        int cellLines = getNumWrappedLines(cell);
        if (cellLines > maxNumLines) {
          maxNumLines = cellLines;
        }
      }
    }
    if (maxNumLines > MAX_ROW_LINES) {
      maxNumLines = MAX_ROW_LINES;
    }
    if (maxNumLines > 1) {
      row.setHeight((short) (sheet.getDefaultRowHeight()*maxNumLines));
    }        
  }
}

代码示例来源:origin: org.spdx/spdx-tools

/**
 * resize the rows for a best fit.  Will not exceed maximum row height.
 */
public void resizeRows() {
  // header row
  // data rows
  int lastRow = this.getNumDataRows()+this.getFirstDataRow()-1;
  for (int i = 0; i <= lastRow; i++) {
    Row row = sheet.getRow(i);
    int lastCell = row.getLastCellNum();	// last cell + 1
    int maxNumLines = 1;
    for (int j = 0; j < lastCell; j++) {
      Cell cell = row.getCell(j);
      if (cell != null) {
        int cellLines = getNumWrappedLines(cell);
        if (cellLines > maxNumLines) {
          maxNumLines = cellLines;
        }
      }
    }
    if (maxNumLines > MAX_ROW_LINES) {
      maxNumLines = MAX_ROW_LINES;
    }
    if (maxNumLines > 1) {
      row.setHeight((short) (sheet.getDefaultRowHeight()*maxNumLines));
    }        
  }
}

相关文章

微信公众号

最新文章

更多