Bug 51098 - Error in calculating image width/height, if image fits into one cell
Summary: Error in calculating image width/height, if image fits into one cell
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 02:03 UTC by kleindienst
Modified: 2011-05-27 18:46 UTC (History)
0 users



Attachments
Modified java file with bug fixed (10.98 KB, application/octet-stream)
2011-04-21 02:03 UTC, kleindienst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kleindienst 2011-04-21 02:03:42 UTC
Created attachment 26918 [details]
Modified java file with bug fixed

Overview

The calculation of image width and height in the class
  XSSFPicture
of the package
  org.apache.poi.xssf.usermodel
has a bug:

If an image fits into one cell (in the second or one of the following columns), the width calculation leads to wrong results, because cw is taken from the next column, which is not relevant in that case:
  double cw = getColumnWidthInPixels(col2 + 1);
A quick and dirty solution would be to check, if the last column (col2) is the same as the first and calculate the dx2 accordingly:
  if (col2 == anchor.getCol1()) {
     = (int) (EMU_PER_PIXEL * scaledWidth);
  }
Same for image height.


Steps to Reproduce

Just ad an image to a an XLSX which fits into one cell (using the XSSF model).


Build Date & Platform

poi-3.7-20101029 on Windows


Attachment

The java file with the corrections is attached. (However, there might be a better way to solve this.)
Comment 1 Yegor Kozlov 2011-05-27 18:46:30 UTC
Fixed in r1128422

Yegor