org.apache.poi.hssf.usermodel.HSSFSheet.getColumnWidth()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(226)

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

HSSFSheet.getColumnWidth介绍

[英]get the width (in units of 1/256th of a character width )
[中]获取宽度(以字符宽度的1/256为单位)

代码示例

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

@Override
public float getColumnWidthInPixels(int column){
  int cw = getColumnWidth(column);
  int def = getDefaultColumnWidth()*256;
  float px = (cw == def ? PX_DEFAULT : PX_MODIFIED);
  return cw/px;
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
 */
public short getColumnWidth(short columnIndex) {
  return (short) getColumnWidth(columnIndex & 0xFFFF);
}

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

/**
 * @deprecated (Sep 2008) use {@link #getColumnWidth(int)}
 */
public short getColumnWidth(short columnIndex) {
  return (short)getColumnWidth(columnIndex & 0xFFFF);
}

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

@Override
public float getColumnWidthInPixels(int column){
  int cw = getColumnWidth(column);
  int def = getDefaultColumnWidth()*256;
  float px = (cw == def ? PX_DEFAULT : PX_MODIFIED);
  return cw/px;
}

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

private float getColumnWidthInPixels(int column){
  int cw = _patriarch._sheet.getColumnWidth(column);
  float px = getPixelWidth(column);
  return cw/px;
}

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

protected static int getColumnWidth( HSSFSheet sheet, int columnIndex )
{
  return ExcelToHtmlUtils.getColumnWidthInPx( sheet
      .getColumnWidth( columnIndex ) );
}

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

private float getPixelWidth(int column){
  int def = _patriarch._sheet.getDefaultColumnWidth()*256;
  int cw = _patriarch._sheet.getColumnWidth(column);
  return cw == def ? PX_DEFAULT : PX_MODIFIED;
}

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

protected static int getColumnWidth( HSSFSheet sheet, int columnIndex )
{
  return ExcelToHtmlUtils.getColumnWidthInPx( sheet
      .getColumnWidth( columnIndex ) );
}

代码示例来源:origin: org.metaeffekt.core/ae-inventory-processor

protected void readArtifactMetaData(HSSFWorkbook myWorkBook, Inventory inventory) {
  HSSFSheet mySheet = myWorkBook.getSheetAt(0);
  Iterator<?> rows = mySheet.rowIterator();
  List<Artifact> artifacts = new ArrayList<Artifact>();
  inventory.setArtifacts(artifacts);
  if (rows.hasNext()) {
    readHeader((HSSFRow) rows.next());
  }
  while (rows.hasNext()) {
    HSSFRow row = (HSSFRow) rows.next();
    Artifact artifact = readArtifactMetaData(row);
    if (artifact != null) {
      artifacts.add(artifact);
    }
  }
  for (int i = 0; i < 15; i++) {
    int width = mySheet.getColumnWidth(i);
    inventory.getContextMap().put("artifacts.column[" + i + "].width", width);
  }
}

代码示例来源:origin: com.haulmont.thirdparty/poi

private float getColumnWidthInPixels(int column){
  int cw = getPatriarch().getSheet().getColumnWidth(column);
  float px = getPixelWidth(column);
  return cw/px;
}

代码示例来源:origin: org.metaeffekt.core/ae-inventory-processor

protected void readLicenseMetaData(HSSFWorkbook myWorkBook, Inventory inventory) {
  if (myWorkBook.getNumberOfSheets() > 1) {
    HSSFSheet mySheet = myWorkBook.getSheetAt(1);
    if (mySheet != null) {
      Iterator<?> rows = mySheet.rowIterator();
      List<LicenseMetaData> licenseMetaDatas = new ArrayList<LicenseMetaData>();
      inventory.setLicenseMetaData(licenseMetaDatas);
      // skip first line being the header
      if (rows.hasNext()) {
        readLicenseMetaDataHeader((HSSFRow) rows.next());
      }
      while (rows.hasNext()) {
        HSSFRow row = (HSSFRow) rows.next();
        LicenseMetaData licenseMetaData = readLicenseMetaData(row);
        if (licenseMetaData != null) {
          licenseMetaDatas.add(licenseMetaData);
        }
      }
    }
    for (int i = 0; i < 5; i++) {
      int width = mySheet.getColumnWidth(i);
      inventory.getContextMap().put("obligations.column[" + i + "].width", width);
    }
  }
}

代码示例来源:origin: ckpoint/CheckPoint

/**
 * Create title cell cell.
 *
 * @param str   the str
 * @param width the width
 * @return the cell
 */
public Cell createTitleCell(String str, double width) {
  int cellCnt = this.getCellCnt();
  Cell cell = this.getLastRow().createCell(cellCnt);
  cell.setCellValue(str);
  cell.setCellType(CellType.STRING);
  cell.setCellStyle(this.style.getStringCs());
  sheet.setColumnWidth(cellCnt, (int) (sheet.getColumnWidth(cellCnt) * width));
  return cell;
}

代码示例来源:origin: com.haulmont.thirdparty/poi

private float getPixelWidth(int column){
  int def = getPatriarch().getSheet().getDefaultColumnWidth()*256;
  int cw = getPatriarch().getSheet().getColumnWidth(column);
  return cw == def ? PX_DEFAULT : PX_MODIFIED;
}

代码示例来源:origin: com.haulmont.yarg/yarg

@Override
  public void apply() {
    for (DataObject dataObject : data) {
      dataObject.resultCell.getSheet().setColumnWidth(dataObject.resultCell.getColumnIndex(), dataObject.templateCell.getSheet().getColumnWidth(dataObject.templateCell.getColumnIndex()));
    }
  }
}

代码示例来源:origin: cuba-platform/yarg

@Override
  public void apply() {
    for (DataObject dataObject : data) {
      dataObject.resultCell.getSheet().setColumnWidth(dataObject.resultCell.getColumnIndex(),
          dataObject.templateCell.getSheet().getColumnWidth(dataObject.templateCell.getColumnIndex()));
    }
  }
}

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

for (int i=0; i< columns.getColumnCount(); i++) {
 TableColumn column = columns.getColumn(i);
 int width = sheet.getColumnWidth(i);

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

for (int i=0; i< columns.getColumnCount(); i++) {
 TableColumn column = columns.getColumn(i);
 int width = sheet.getColumnWidth(i);

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

for (int i=0; i< columns.getColumnCount(); i++) {
 TableColumn column = columns.getColumn(i);
 int width = sheet.getColumnWidth(i);

代码示例来源:origin: com.github.hazendaz/displaytag

/**
 * Uses POI Autosizing. WARNING. This has been known to cause performance problems and various exceptions. use at
 * your own risk! Overriding this method is suggested. From POI HSSF documentation for autoSizeColumn: "To calculate
 * column width HSSFSheet.autoSizeColumn uses Java2D classes that throw exception if graphical environment is not
 * available. In case if graphical environment is not available, you must tell Java that you are running in headless
 * mode and set the following system property: java.awt.headless=true."
 */
protected void autosizeColumns()
{
  for (int i = 0; i < getModel().getNumberOfColumns(); i++)
  {
    getSheet().autoSizeColumn((short) i);
    // since this usually creates column widths that are just too short, adjust here!
    // gives column width an extra character
    int width = getSheet().getColumnWidth(i);
    width += 256;
    getSheet().setColumnWidth(i, (short) width);
  }
}

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

private void drawLabel(HSSFSheet sheet, HSSFCell cell) {
  final int defaultColumnWidth = 2048; // column width before resizing
  final int defaultRowHeight = 255; // row height before resizing
  final double xDistortionFactor = 1.0 * defaultColumnWidth / sheet.getColumnWidth(cell.getColumnIndex());
  final double yDistortionFactor = 1.0 * defaultRowHeight / cell.getRow().getHeight();

  final int dx1 = (int) (60 * xDistortionFactor);
  final int dy1 = (int) (60 * yDistortionFactor);
  final int dx2 = (int) (200 * xDistortionFactor);
  final int dy2 = (int) (200 * yDistortionFactor);
  final short columnIndex = (short) cell.getColumnIndex();
  final int rowIndex = cell.getRowIndex();
  final HSSFClientAnchor anchor = new HSSFClientAnchor(dx1, dy1, dx2, dy2, columnIndex, rowIndex, columnIndex, rowIndex);
  anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);

  HSSFSimpleShape shape = sheet.getDrawingPatriarch().createSimpleShape(anchor);
  shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL);
  ...
}

相关文章

HSSFSheet类方法