Picture data is a workbook-global object and can be shared between multiple
pictures.
Just pass the same picture index in patriarch.createPicture.
public void main(String[] args) throws IOException {
//read picture bytes from file system
byte[] data = readPicture("checkbox.jpg");
HSSFWorkbook wb = new HSSFWorkbook();
//picture data is a workbook-global object and can be shared between
multiple pictures
int pictureIndex = wb.addPicture(data, HSSFPicture.PICTURE_TYPE_JPEG);
HSSFSheet sheet = wb.createSheet();
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
//all pictures use the same picture index, thus sharing the same
picture data
HSSFPicture pic1 = patriarch.createPicture(new HSSFClientAnchor(0, 0,
0, 0,
(short)0, 0, (short)1, 1), pictureIndex);
HSSFPicture pic2 = patriarch.createPicture(new HSSFClientAnchor(0, 0,
0, 0,
(short)2, 2, (short)3, 3), pictureIndex);
HSSFPicture pic3 = patriarch.createPicture(new HSSFClientAnchor(0, 0,
0, 0,
(short)4, 4, (short)5, 5), pictureIndex);
FileOutputStream out = new FileOutputStream("shared_picture_data.xls");
wb.write(out);
out.close();
}
Oh, yeah. I'd like to be able to use pictures of checkboxes and
radiobuttons too (which my PDFs do). Or, does Excel somehow support native
checkboxes and/or radiobuttons in cells (don't see it anywhere)?
Native checkboxes and radiobuttons are not yet supported.
Yegor
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]