It looks like a bug in XSSF. Can you create a Bugzilla ticket and post
a sample code that shows the trouble ?

Yegor

On Mon, Jan 23, 2012 at 2:37 PM, Felipe Issa <[email protected]> wrote:
> I have tried that, but when I call resize() it resets the dx1 and dy1 to 0,
> and that is not what I want! I need the picture to be in the middle of the
> Cell.
>
> Felipe
> Em 20/01/2012 11:26, Yegor Kozlov escreveu:
>
>> You need to call Picture.resize() in the end:
>>
>> Picture pict = drawing.createPicture(anchor, pictureIdx)
>> pict.resize();
>>
>> Yegor
>>
>> On Fri, Jan 20, 2012 at 4:35 PM, Felipe Issa<[email protected]>
>>  wrote:
>>>
>>> Hi. I'm using apache poi 3.8 beta 5 (20111217) and i can't get it to
>>> insert
>>> a picture on a XSSFWorkbook.
>>> It works just fine when i try to insert it on a HSSFWorkbook, but when i
>>> change the type of the file it doesn't show anything on the sheet.
>>> Does anyone knows how to fix this? Is it a bug?
>>>
>>> Here is the code i'm using:
>>>
>>> public void insertPicture() throws Exception{
>>>        /*
>>>         * 0 = HSSFWorkbook
>>>         * anything else = XSSFWorkbook
>>>         */
>>>        int type = 1;
>>>
>>>        Workbook wb = null;
>>>
>>>        if(type == 0){
>>>            wb = new HSSFWorkbook();
>>>        }else{
>>>            wb = new XSSFWorkbook();
>>>        }
>>>        CreationHelper createHelper = wb.getCreationHelper();
>>>
>>>        StringBuffer sb = new StringBuffer();
>>>        sb.append("C:\\temp\\");
>>>        File f = new File(sb.toString());
>>>        if (!f.isDirectory()) {
>>>            f.mkdirs();
>>>        }
>>>
>>>        String dataHoje = new
>>> SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Util.getCurrentDate());
>>>        sb.append("file_");
>>>        sb.append(dataHoje);
>>>        if(type == 0){
>>>            sb.append(".xls");
>>>        }else{
>>>            sb.append(".xlsx");
>>>        }
>>>
>>>
>>>        File arquivo = new File(sb.toString());
>>>        if (!arquivo.exists()) {
>>>            arquivo.createNewFile();
>>>        }
>>>
>>>        FileOutputStream outputStream;
>>>        Sheet sheet = null;
>>>
>>>        try {
>>>            outputStream =  new FileOutputStream(arquivo);
>>>            sheet = wb.createSheet();
>>>            Drawing patriarch= sheet.createDrawingPatriarch();
>>>            ClientAnchor anchor = createHelper.createClientAnchor();
>>>            anchor.setCol1(4);
>>>            anchor.setCol2(4);
>>>            anchor.setRow1(0);
>>>            anchor.setRow2(0);
>>>            anchor.setDx1(400);
>>>            anchor.setDx2(655);
>>>            anchor.setDy1(10);
>>>            anchor.setDy2(200);
>>>
>>>            anchor.setAnchorType(1);
>>>            File pic = new File("C:\\Temp\\img_ok.png");
>>>            long length = pic.length(  );
>>>            byte[]picData = new byte[ ( int ) length ];
>>>            FileInputStream picIn = new FileInputStream( pic );
>>>            picIn.read(picData);
>>>            int index = wb.addPicture(picData, wb.PICTURE_TYPE_PNG);
>>>            patriarch.createPicture(anchor,index);
>>>
>>>
>>>            wb.write(outputStream);
>>>            outputStream.close();
>>>        } catch (Exception e) {
>>>            throw e;
>>>        }
>>>    }
>>>
>>> Thanks in advice!
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to