0

I'm using POI to create excel report file in java. My report contains report data and also some pictures in it. my problem is when I add a picture to my excel(it's created by custom font and custom font size) picture being stretched.

I'm using this approach : https://stackoverflow.com/a/34908675/354373 but it needs to determine one of width or hight and calculate other one, it means that one of width or hight should be specified and constant. but I want to show picture in excel in original size(without any stretch in width or hight).

PS : I want to add picture in one row and one or more column depends on image width. my concern is finding appropriate row hight and number of columns (or column width) based on the original image size.

Any guidance or sample code will be appreciate.

Community
  • 1
  • 1
amin10043
  • 234
  • 3
  • 7
  • is the picture a file or is it created in java? – XtremeBaumer Dec 01 '16 at 12:02
  • it's a file, and available as byte[]. – amin10043 Dec 01 '16 at 12:04
  • 2
    http://poi.apache.org/spreadsheet/quick-guide.html#Images this might help you if you have adding problems. for the size you can try reading the hex values from the file. i'd guess you can find size in there – XtremeBaumer Dec 01 '16 at 12:12
  • I used that samples but it's still stretched. is there any sample code or tutorial for that? :( – amin10043 Dec 01 '16 at 12:54
  • Maybe a [OneCellAnchor](http://stackoverflow.com/questions/19291948) solves the stretching, this assumes you've determined the image size beforehand e.g. with ImageIO – kiwiwings Dec 04 '16 at 08:37

0 Answers0