public static class ExcelExport.ImageCell extends Object
Constructor and Description |
---|
ImageCell(byte[] fileData,
int colWidthInPixel,
String fileName)
Creates a new cell containing an image which could be inserted into an Excel sheet.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getHeightInPoints()
Converted height in pixels of row containing the image as POI uses points as unit for row heights.
|
protected int |
getPOIWidth()
Returns width of column containing the image formatted in POI's unit for pixel width.
|
protected float |
getScaleFactor()
Calculates the scale factor images should be scaled to so that they fit into the set column width.
|
public ImageCell(byte[] fileData, int colWidthInPixel, String fileName)
The height of the image determines the height of the row containing the image. Currently, only one image is allowed per row as the changes in height for the row might result in distorted images.
Images are scaled to fit in a cell. Their scaling is determined by their width and the parameter colWidthInPixel. Images are only scaled down but never up.
Only the first image cell inserted in a given column is able to set the width of the column as changing a column's width while images being present in the column would result in them beind distorted.
The filename is needed in order to determine the type of image. POI requires an image type for inserting images. Only jpeg, png and bmp are supported.
fileData
- the data of the picturecolWidthInPixel
- the width of the column containing the image should havefileName
- the filename or path to file containing the filenameprotected int getHeightInPoints()
protected int getPOIWidth()
Adapted from: https://stackoverflow.com/a/31837639
protected float getScaleFactor()
Copyright © 2018. All rights reserved.