https://issues.apache.org/bugzilla/show_bug.cgi?id=46515
Summary: Error in adding jpg to a workbook that has a sheet with
a checkbox control
Product: POI
Version: 3.2-FINAL
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: major
Priority: P2
Component: HSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
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();
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]