Bug 46515

Summary: Error in adding jpg to a workbook that has a sheet with a checkbox control
Product: POI Reporter: Laird Trimble <laird.trimble>
Component: HSSFAssignee: POI Developers List <dev>
Severity: major CC: laird.trimble
Priority: P2    
Version: 3.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Imput xls file
Output file showing error

Description Laird Trimble 2009-01-12 13:23:30 UTC
I have a workbook with two sheets.  The first sheet has one checkbox control on it.  The second sheet is empty.

When I use POI to add an image to the empty spreadsheet, it corrupts the appearence of the checkbox in the first sheet.  

This behavior happens with 2.2-Final and the latest build that I could get, poi-3.5-beta4-20081217.jar.

The code that I use is shown below:

            FileInputStream input = new FileInputStream(new File(templatePath));
            POIFSFileSystem fs = new POIFSFileSystem(input);
            wb = new HSSFWorkbook(fs);

            // Get structure from webservice
            String urlString = "http://urlpath/etc);
            URL structURL = new URL(urlString);
            BufferedImage bimage = ImageIO.read(structURL);

            // Convert BufferedImage to byte[]
            ByteArrayOutputStream imageBAOS = new ByteArrayOutputStream();
            ImageIO.write(bimage, "jpeg", imageBAOS);
            byte[]imageBytes = imageBAOS.toByteArray();

            // Pop structure into Structure HSSFSheet
            int pict = wb.addPicture(imageBytes, HSSFWorkbook.PICTURE_TYPE_JPEG);
            HSSFPatriarch patriarch = wb.getSheet("Structure").createDrawingPatriarch();
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) 1, 1, (short) 10, 22);
            patriarch.createPicture(anchor, pict);

            // Write out destination file
            FileOutputStream fileOut = new FileOutputStream(destinationFile);
Comment 1 Laird Trimble 2009-01-12 13:24:48 UTC
Created attachment 23106 [details]
Imput xls file

This is the input file used to demostrate this bug
Comment 2 Laird Trimble 2009-01-12 13:26:12 UTC
Created attachment 23107 [details]
Output file showing error

This is the output file with the munged checkbox on the first sheet.
Comment 3 Dominik Stadler 2015-09-29 07:46:18 UTC
I could not reproduce this any more on 3.13/trunk so I think this is fixed in the meantime.