Hi, thanks for your reply.
I tried something like this too. The problem with this algorithm is, that a picture in the next row and same column may be smaller than the width of the column. If that is the case it should keep its size. -------- Original-Nachricht -------- > Datum: Thu, 11 Sep 2008 17:38:48 +0200 > Von: "Pierre Lavignotte" <[EMAIL PROTECTED]> > An: "POI Users List" <[email protected]> > Betreff: Re: setting excel cells to a specific width and height in pixel > Hi, > > I've found this piece of code in my test project. > > I can't remember why some code is commented out, but I know that 1023 > and 255 values mean that you fill the cell with the image (ie 100%). > > private void drawImage(short col, int row, InputStream in, > HSSFWorkbook workbook, > HSSFPatriarch patriarch) throws IOException, > NullPointerException { > if (in == null) { > throw new NullPointerException("Fichier image null"); > } > > //Conversion de l'image au format png(format de JEXCEL). > ByteArrayOutputStream out = new ByteArrayOutputStream(); > BufferedImage input = ImageIO.read(in); > ImageIO.write(input, "PNG", out); > > double imgWidth = input.getWidth(); > double imgHeight = input.getHeight(); > // double ratio = imgWidth / imgHeight; > // double ratioXl = 1; //sizeColum/sizeRow; > // double SIZE_LIMIT_WIDTH = 0.9; > // double SIZE_LIMIT_HEIGHT = SIZE_LIMIT_WIDTH * ratioXl; > // > // if (imgHeight <= imgWidth) { > // imgWidth = SIZE_LIMIT_WIDTH; > // imgHeight = (SIZE_LIMIT_HEIGHT / ratio); > // } else { > // imgHeight = SIZE_LIMIT_HEIGHT; > // imgWidth = SIZE_LIMIT_WIDTH * ratio; > // } > > HSSFClientAnchor anchor; > anchor = new HSSFClientAnchor(0, 0, 1023, 255, > col, row, col, row); > > anchor.setAnchorType(2); > > int pictureIndex = workbook.addPicture(out.toByteArray(), > HSSFWorkbook.PICTURE_TYPE_PNG); > > patriarch.createPicture(anchor, pictureIndex); > } > > Hope it helps, > > Pierre > > On Thu, Sep 11, 2008 at 5:34 PM, Nick Burch <[EMAIL PROTECTED]> wrote: > > On Thu, 11 Sep 2008, Thorsten Bux wrote: > >> > >> does anybody know how to set the width and height of an excel cell to a > >> specific size in pixel? > > > > I think the two methods you'll want are: > > > http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html#setHeightInPoints(float) > > > http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFSheet.html#setColumnWidth(short,%20short) > > > >> also i would like to know how to set a cell to the max. possible height > >> and width. > > > > Try giving those two methods really large values? (Not sure, haven't > tried) > > > > Nick > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > Cordialement, > Pierre Lavignotte > Ingénieur Conception & Développement > http://pierre.lavignotte.googlepages.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/[EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
