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

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

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

Sheet.getDefaultRowHeightInPoints介绍

[英]Get the default row height for the sheet (if the rows do not define their own height) in points.
[中]以点为单位获取图纸的默认行高(如果行未定义自己的高度)。

代码示例

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

public static double getRowHeightInPixels(Sheet sheet, int rowNum) {
    Row r = sheet.getRow(rowNum);
    double points = (r == null) ? sheet.getDefaultRowHeightInPoints() : r.getHeightInPoints();
    return Units.toEMU(points)/(double)EMU_PER_PIXEL;
  }
}

代码示例来源: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: org.openl.rules/org.openl.lib.poi.dev

/**
 * Returns row height measured in point size. If the height is not set, the default worksheet value is returned,
 * See {@link Sheet#getDefaultRowHeightInPoints()}
 *
 * @return row height measured in point size
 * @see Sheet#getDefaultRowHeightInPoints()
 */
public float getHeightInPoints()
{
  return (float)(_height==-1?getSheet().getDefaultRowHeightInPoints():(float)_height/20.0);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Get the row's height measured in twips (1/20th of a point). If the height is not set, the default worksheet value is returned,
 * See {@link Sheet#getDefaultRowHeightInPoints()}
 *
 * @return row height measured in twips (1/20th of a point)
 */
public short getHeight()
{
  return (short)(_height==-1?getSheet().getDefaultRowHeightInPoints()*20:_height);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

public static double getRowHeightInPixels(Sheet sheet, int rowNum) {
    Row r = sheet.getRow(rowNum);
    double points = (r == null) ? sheet.getDefaultRowHeightInPoints() : r.getHeightInPoints();
    return Units.toEMU(points)/(double)EMU_PER_PIXEL;
  }
}

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

public static void main(String[]args) throws IOException {
    try (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 accommodate two lines of text
      row.setHeightInPoints(2 * sheet.getDefaultRowHeightInPoints());

      //adjust column width to fit the content
      sheet.autoSizeColumn(2);

      try (FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx")) {
        wb.write(fileOut);
      }
    }
  }
}

相关文章

微信公众号

最新文章

更多