public class AddDimensionedImage extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
AddDimensionedImage.ClientAnchorDetail
The HSSFClientAnchor class accepts eight arguments.
|
static class |
AddDimensionedImage.ConvertImageUnits
Utility methods used to convert Excels character based column and row
size measurements into pixels and/or millimetres.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
EXPAND_COLUMN |
static int |
EXPAND_ROW |
static int |
EXPAND_ROW_AND_COLUMN |
static int |
OVERLAY_ROW_AND_COLUMN |
| Constructor and Description |
|---|
AddDimensionedImage() |
| Modifier and Type | Method and Description |
|---|---|
void |
addImageToSheet(int colNumber,
int rowNumber,
Sheet sheet,
Drawing<?> drawing,
URL imageFile,
double reqImageWidthMM,
double reqImageHeightMM,
int resizeBehaviour)
Add an image to a worksheet.
|
void |
addImageToSheet(String cellNumber,
Sheet sheet,
Drawing<?> drawing,
URL imageFile,
double reqImageWidthMM,
double reqImageHeightMM,
int resizeBehaviour)
Add an image to a worksheet.
|
static void |
main(String[] args)
The main entry point to the program.
|
public static final int EXPAND_ROW
public static final int EXPAND_COLUMN
public static final int EXPAND_ROW_AND_COLUMN
public static final int OVERLAY_ROW_AND_COLUMN
public void addImageToSheet(String cellNumber, Sheet sheet, Drawing<?> drawing, URL imageFile, double reqImageWidthMM, double reqImageHeightMM, int resizeBehaviour) throws IOException, IllegalArgumentException
cellNumber - A String that contains the location of the cell whose
top left hand corner should be aligned with the top
left hand corner of the image; for example "A1", "A2"
etc. This is to support the familiar Excel syntax.
Whilst images are not actually inserted into cells
this provides a convenient method of indicating where
the image should be positioned on the sheet.sheet - A reference to the sheet that contains the cell referenced
above.drawing - An instance of the DrawingPatriarch class. This is now
passed into the method where it was, previously, recovered
from the sheet in order to allow multiple pictures be
inserted. If the patriarch was not 'cached in this manner
each time it was created any previously positioned images
would be simply over-written.imageFile - An instance of the URL class that encapsulates the name
of and path to the image that is to be 'inserted into'
the sheet.reqImageWidthMM - A primitive double that contains the required
width of the image in millimetres.reqImageHeightMM - A primitive double that contains the required
height of the image in millimetres.resizeBehaviour - A primitive int whose value will determine how
the code should react if the image is larger than
the cell referenced by the cellNumber parameter.
Four constants are provided to determine what
should happen;
AddDimensionedImage.EXPAND_ROW
AddDimensionedImage.EXPAND_COLUMN
AddDimensionedImage.EXPAND_ROW_AND_COLUMN
AddDimensionedImage.OVERLAY_ROW_AND_COLUMNFileNotFoundException - If the file containing the image
cannot be located.IOException - If a problem occurs whilst reading the file
of image data.IllegalArgumentException - If an invalid value is passed
to the resizeBehaviour
parameter.public void addImageToSheet(int colNumber,
int rowNumber,
Sheet sheet,
Drawing<?> drawing,
URL imageFile,
double reqImageWidthMM,
double reqImageHeightMM,
int resizeBehaviour)
throws IOException,
IllegalArgumentException
colNumber - A primitive int that contains the index number of a
column on the worksheet; POI column indices are zero
based. Together with the rowNumber parameter's value,
this parameter identifies a cell on the worksheet. The
images top left hand corner will be aligned with the
top left hand corner of this cell.rowNumber - A primitive int that contains the index number of a row
on the worksheet; POI row indices are zero based.
Together with the rowNumber parameter's value, this
parameter identifies a cell on the worksheet. The
images top left hand corner will be aligned with the
top left hand corner of this cell.sheet - A reference to the sheet that contains the cell identified
by the two parameters above.drawing - An instance of the DrawingPatriarch class. This is now
passed into the method where it was, previously, recovered
from the sheet in order to allow multiple pictures be
inserted. If the patriarch was not 'cached in this manner
each time it was created any previously positioned images
would be simply over-written.imageFile - An instance of the URL class that encapsulates the name
of and path to the image that is to be 'inserted into'
the sheet.reqImageWidthMM - A primitive double that contains the required
width of the image in millimetres.reqImageHeightMM - A primitive double that contains the required
height of the image in millimetres.resizeBehaviour - A primitive int whose value will determine how
the code should react if the image is larger than
the cell referenced by the colNumber and
rowNumber parameters. Four constants are provided
to determine what should happen;
AddDimensionedImage.EXPAND_ROW
AddDimensionedImage.EXPAND_COLUMN
AddDimensionedImage.EXPAND_ROW_AND_COLUMN
AddDimensionedImage.OVERLAY_ROW_AND_COLUMNFileNotFoundException - If the file containing the image
cannot be located.IOException - If a problem occurs whilst reading the file
of image data.IllegalArgumentException - If an invalid value is passed
to the resizeBehaviour
parameter or if the extension
of the image file indicates that
it is of a type that cannot
currently be added to the worksheet.public static void main(String[] args) throws IOException
args - the command line argumentsIOException