@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; }
/** * @deprecated (Sep 2008) use {@link #getColumnWidth(int)} */ public short getColumnWidth(short columnIndex) { return (short) getColumnWidth(columnIndex & 0xFFFF); }
/** * @deprecated (Sep 2008) use {@link #getColumnWidth(int)} */ public short getColumnWidth(short columnIndex) { return (short)getColumnWidth(columnIndex & 0xFFFF); }
@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; }
private float getColumnWidthInPixels(int column){ int cw = _patriarch._sheet.getColumnWidth(column); float px = getPixelWidth(column); return cw/px; }
protected static int getColumnWidth( HSSFSheet sheet, int columnIndex ) { return ExcelToHtmlUtils.getColumnWidthInPx( sheet .getColumnWidth( columnIndex ) ); }
private float getPixelWidth(int column){ int def = _patriarch._sheet.getDefaultColumnWidth()*256; int cw = _patriarch._sheet.getColumnWidth(column); return cw == def ? PX_DEFAULT : PX_MODIFIED; }
protected static int getColumnWidth( HSSFSheet sheet, int columnIndex ) { return ExcelToHtmlUtils.getColumnWidthInPx( sheet .getColumnWidth( columnIndex ) ); }
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); } }
private float getColumnWidthInPixels(int column){ int cw = getPatriarch().getSheet().getColumnWidth(column); float px = getPixelWidth(column); return cw/px; }
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); } } }
/** * 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; }
private float getPixelWidth(int column){ int def = getPatriarch().getSheet().getDefaultColumnWidth()*256; int cw = getPatriarch().getSheet().getColumnWidth(column); return cw == def ? PX_DEFAULT : PX_MODIFIED; }
@Override public void apply() { for (DataObject dataObject : data) { dataObject.resultCell.getSheet().setColumnWidth(dataObject.resultCell.getColumnIndex(), dataObject.templateCell.getSheet().getColumnWidth(dataObject.templateCell.getColumnIndex())); } } }
@Override public void apply() { for (DataObject dataObject : data) { dataObject.resultCell.getSheet().setColumnWidth(dataObject.resultCell.getColumnIndex(), dataObject.templateCell.getSheet().getColumnWidth(dataObject.templateCell.getColumnIndex())); } } }
for (int i=0; i< columns.getColumnCount(); i++) { TableColumn column = columns.getColumn(i); int width = sheet.getColumnWidth(i);
for (int i=0; i< columns.getColumnCount(); i++) { TableColumn column = columns.getColumn(i); int width = sheet.getColumnWidth(i);
for (int i=0; i< columns.getColumnCount(); i++) { TableColumn column = columns.getColumn(i); int width = sheet.getColumnWidth(i);
/** * 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); } }
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); ... }