public class ImageHandle extends Object implements Serializable
insert images into your spreadsheet set the position of the image set the width and height of the image write spreadsheet image files to any outputstream
WorkBookHandle,
WorkSheetHandle,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
HEIGHT |
static int |
WIDTH |
static int |
X |
static int |
Y |
| Constructor and Description |
|---|
ImageHandle(byte[] _imageBytes,
Boundsheet sheet)
Constructor which takes image file bytes and inserts into
specific sheet
|
ImageHandle(InputStream imagebytestream,
Boundsheet bs)
Constructor which takes image file bytes and associates it with the
specified boundsheet
|
ImageHandle(InputStream imagebytestream,
WorkSheetHandle _sheet)
Constructor which takes image file bytes and inserts into
specific sheet
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
convertData(InputStream imagebytestream)
converts image data into byte array used by
Jan 22, 2010
|
boolean |
equals(Object another)
Override equals so that Sheet cannot contain dupes.
|
double |
getAspectRatio()
returns width divided by height for the aspect ratio
|
short[] |
getBounds()
return the image bounds
images bounds are as follows:
bounds[0]= column # of top left position (0-based) of the shape
bounds[1]= x offset within the top-left column (0-1023)
bounds[2]= row # for top left corner
bounds[3]= y offset within the top-left corner (0-1023)
bounds[4]= column # of the bottom right corner of the shape
bounds[5]= x offset within the cell for the bottom-right corner (0-1023)
bounds[6]= row # for bottom-right corner of the shape
bounds[7]= y offset within the cell for the bottom-right corner (0-1023)
|
int |
getCol()
return the leftmost column of the image
|
int |
getCol1()
return the rightmost column of the image
|
short[] |
getColAndOffset()
get the position of the top left corner of the image in the sheet
|
short[] |
getCoords()
return the image bounds in x, y, width, height format in pixels
|
short |
getHeight()
return the height of the image in pixels
|
byte[] |
getImageBytes() |
String |
getImageFormat(InputStream imagebytestream)
returns the format name of the image data
Jan 22, 2010
|
int |
getImageIndex()
Internal method that converts the image bounds appropriate for saving
by Excel in the MsofbtOPT record.
|
String |
getImageName()
return the imageName (= original file name, I believe)
|
int |
getImageType() |
org.json.JSONObject |
getJSON()
Get a JSON representation of the format
|
String |
getMimeType()
Returns the image mime type
|
MSODrawing |
getMsodrawing() |
String |
getName() |
String |
getOOXML(int rId)
return the (00)XML (or DrawingML) representation of this image
|
int |
getOriginalWidth() |
int |
getRow()
return the topmost row of the image
|
int |
getRow1()
return the lower row of the image
|
short[] |
getRowAndOffset()
get the position of the top left corner of the image in the sheet
|
String |
getShapeName()
returns the explicitly set shape name (set by entering text in the named range field in Excel)
|
Boundsheet |
getSheet()
returns the WorkSheet this image is contained in
|
SpPr |
getSpPr()
return the OOXML shape property for this image
|
String |
getType()
Returns the image type
|
short |
getWidth()
return the width of the image in pixels
|
short |
getX()
return the upper x coordinate of the image in pixels
|
String |
getXML(int rId)
return the XML representation of this image
|
short |
getY()
return the upper y coordinate of the image in pixels
|
boolean |
isActive()
returns true if this drawing is active i.e.
|
void |
position(ImageHandle im)
set ImageHandle position based on another
|
boolean |
remove()
removes this Image from the WorkBook.
|
void |
setBounds(short[] bounds)
sets the image bounds
images bounds are as follows:
bounds[0]= column # of top left position (0-based) of the shape
bounds[1]= x offset within the top-left column (0-1023)
bounds[2]= row # for top left corner
bounds[3]= y offset within the top-left corner (0-1023)
bounds[4]= column # of the bottom right corner of the shape
bounds[5]= x offset within the cell for the bottom-right corner (0-1023)
bounds[6]= row # for bottom-right corner of the shape
bounds[7]= y offset within the cell for the bottom-right corner (0-1023)
|
void |
setCoords(int x,
int y,
int w,
int h)
set the image x, w, width and height in pixels
|
void |
setEditMovement(String editMovement)
specify how to resize or move upon edit OOXML specific
|
void |
setHeight(int h)
set the height of the image in pixels
|
void |
setImageBytes(byte[] imageBytes)
sets the underlying image bytes to the bytes from a new image
essentially swapping the image bytes for another, while retaining
all other image properties (borders, etc.)
|
void |
setImageType(int type) |
void |
setMsgdrawing(MSODrawing rec) |
void |
setName(String name) |
void |
setRow(int row)
set the topmost row of the image
|
void |
setRow1(int row)
set the lower row of the image
|
void |
setShapeName(String name)
allow setting of image name as seen in the Named Range Box
|
void |
setSpPr(SpPr sp)
define the OOXML shape property for this image from an existing spPr element
|
void |
setWidth(int w)
set the width of the image in pixels
|
void |
setX(int x)
set the image upper x coordinate in pixels
|
void |
setY(int y)
set the image upper y coordinate in pixels
|
String |
toString()
Need to figure out a unique identifier for these -- if there
is one in the BIFF8 information, that would be best
|
void |
update()
update the underlying image record
|
void |
write(OutputStream out)
write the image bytes to an outputstream such as a file
|
public static final int X
public static final int Y
public static final int WIDTH
public static final int HEIGHT
public ImageHandle(InputStream imagebytestream, WorkSheetHandle _sheet)
imageBytes - sheet - public ImageHandle(InputStream imagebytestream, Boundsheet bs)
imagebytestream - bs - public ImageHandle(byte[] _imageBytes,
Boundsheet sheet)
imageBytes - sheet - public double getAspectRatio()
public void setMsgdrawing(MSODrawing rec)
public MSODrawing getMsodrawing()
public String getType()
public String getMimeType()
public boolean equals(Object another)
equals in class ObjectObject.equals(java.lang.Object)public boolean isActive()
public byte[] convertData(InputStream imagebytestream)
imagebytestream - public String getImageFormat(InputStream imagebytestream)
imagebytestream - public short[] getBounds()
public void setBounds(short[] bounds)
public short[] getCoords()
public void setCoords(int x,
int y,
int w,
int h)
x - y - w - h - public void setX(int x)
x - public void setY(int y)
y - public int getRow()
public int getRow1()
public void setRow(int row)
row - public void setRow1(int row)
row - public int getCol()
public int getCol1()
public int getOriginalWidth()
public short getWidth()
public void setWidth(int w)
w - public short getHeight()
public void setHeight(int h)
h - public short getX()
public short getY()
public short[] getRowAndOffset()
public short[] getColAndOffset()
public int getImageIndex()
public void write(OutputStream out) throws IOException
out - IOExceptionpublic String toString()
toString in class ObjectObject.toString()public boolean remove()
public int getImageType()
public void setImageType(int type)
image_type - The image type to set.public Boundsheet getSheet()
public String getName()
public String getImageName()
public String getShapeName()
public void setName(String name)
name - The name to set.public void setShapeName(String name)
name - public byte[] getImageBytes()
public void setImageBytes(byte[] imageBytes)
imageBytes - The imageBytes to set.public org.json.JSONObject getJSON()
cr - public void position(ImageHandle im)
im - source ImageHandlepublic String getXML(int rId)
public String getOOXML(int rId)
rId - relationship id for image filepublic SpPr getSpPr()
public void setSpPr(SpPr sp)
public void setEditMovement(String editMovement)
editMovement - Copyright © 2002–2019 Starter Inc.. All rights reserved.