Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. //add picture data to this workbook.
  2. InputStream is = new FileInputStream("/sdcard/MYAPPFOLDER/logo_app.png");
  3. byte[] bytes = IOUtils.toByteArray(is);
  4. int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
  5. is.close();
  6.  
  7. CreationHelper helper = workbook.getCreationHelper();
  8.  
  9. // Create the drawing patriarch. This is the top level container for all shapes.
  10. Drawing drawing = sheet.createDrawingPatriarch();
  11.  
  12. //add a picture shape
  13. ClientAnchor anchor = helper.createClientAnchor();
  14. //set top-left corner of the picture,
  15. //subsequent call of Picture#resize() will operate relative to it
  16. anchor.setCol1(0);
  17. anchor.setRow1(0);
  18. Picture pict = drawing.createPicture(anchor, pictureIdx);
  19.  
  20. //auto-size picture relative to its top-left corner
  21. pict.resize();
  22.  
  23. 02-21 10:10:51.466: E/AndroidRuntime(31691): FATAL EXCEPTION: main
  24. 02-21 10:10:51.466: E/AndroidRuntime(31691): java.lang.NoClassDefFoundError: java.awt.Dimension
  25. 02-21 10:10:51.466: E/AndroidRuntime(31691): at org.apache.poi.ss.util.ImageUtils.getImageDimension(ImageUtils.java:52)
  26. 02-21 10:10:51.466: E/AndroidRuntime(31691): at org.apache.poi.hssf.usermodel.HSSFPicture.getImageDimension(HSSFPicture.java:243)
  27. 02-21 10:10:51.466: E/AndroidRuntime(31691): at org.apache.poi.hssf.usermodel.HSSFPicture.getPreferredSize(HSSFPicture.java:163)
  28.  
  29. pict.resize();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement