Bug 46515 - Error in adding jpg to a workbook that has a sheet with a checkbox control
Summary: Error in adding jpg to a workbook that has a sheet with a checkbox control
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.2-FINAL
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-12 13:23 UTC by Laird Trimble
Modified: 2015-09-29 07:46 UTC (History)
1 user (show)



Attachments
Imput xls file (16.50 KB, application/octet-stream)
2009-01-12 13:24 UTC, Laird Trimble
Details
Output file showing error (32.50 KB, application/vnd.ms-excel)
2009-01-12 13:26 UTC, Laird Trimble
Details

Note You need to log in before you can comment on or make changes to this bug.
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);
            imageBAOS.flush();
            byte[]imageBytes = imageBAOS.toByteArray();
            imageBAOS.close();

            // 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);
            anchor.setAnchorType(2);
            patriarch.createPicture(anchor, pict);

            // Write out destination file
            FileOutputStream fileOut = new FileOutputStream(destinationFile);
            wb.write(fileOut);
            fileOut.close();
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.