- java.lang.Object
-
- org.dhatim.fastexcel.PictureAnchor
-
public class PictureAnchor extends Object
Defines the positioning of an image within a worksheet. Supports both one-cell and two-cell anchoring.One-cell anchor: Image is positioned at a cell with explicit size (width/height). Two-cell anchor: Image spans from one cell to another, resizing with cells.
-
-
Field Summary
Fields Modifier and Type Field Description static intEMU_PER_CMEMUs per centimeter.static intEMU_PER_INCHEMUs per inch.static intEMU_PER_PIXELEMUs (English Metric Units) per pixel at 96 DPI.static intEMU_PER_POINTEMUs per point.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LonggetHeightEmu()Get height in EMUs (for one-cell anchors).LonggetWidthEmu()Get width in EMUs (for one-cell anchors).booleanisTwoCellAnchor()Check if this anchor is a two-cell anchor.static PictureAnchoroneCellAnchor(int row, int col, int widthPx, int heightPx)Create a one-cell anchor with explicit size in pixels.static PictureAnchoroneCellAnchor(int row, int col, int colOffPx, int rowOffPx, int widthPx, int heightPx)Create a one-cell anchor with offset and explicit size in pixels.static PictureAnchortwoCellAnchor(int fromRow, int fromCol, int toRow, int toCol)Create a two-cell anchor spanning from one cell to another.static PictureAnchortwoCellAnchor(int fromRow, int fromCol, int fromColOffPx, int fromRowOffPx, int toRow, int toCol, int toColOffPx, int toRowOffPx)Create a two-cell anchor with offsets.
-
-
-
Field Detail
-
EMU_PER_PIXEL
public static final int EMU_PER_PIXEL
EMUs (English Metric Units) per pixel at 96 DPI.- See Also:
- Constant Field Values
-
EMU_PER_POINT
public static final int EMU_PER_POINT
EMUs per point.- See Also:
- Constant Field Values
-
EMU_PER_INCH
public static final int EMU_PER_INCH
EMUs per inch.- See Also:
- Constant Field Values
-
EMU_PER_CM
public static final int EMU_PER_CM
EMUs per centimeter.- See Also:
- Constant Field Values
-
-
Method Detail
-
oneCellAnchor
public static PictureAnchor oneCellAnchor(int row, int col, int widthPx, int heightPx)
Create a one-cell anchor with explicit size in pixels.- Parameters:
row- Zero-based row numbercol- Zero-based column numberwidthPx- Image width in pixelsheightPx- Image height in pixels- Returns:
- A new PictureAnchor configured for one-cell anchoring
-
oneCellAnchor
public static PictureAnchor oneCellAnchor(int row, int col, int colOffPx, int rowOffPx, int widthPx, int heightPx)
Create a one-cell anchor with offset and explicit size in pixels.- Parameters:
row- Zero-based row numbercol- Zero-based column numbercolOffPx- Column offset in pixels from the left edge of the cellrowOffPx- Row offset in pixels from the top edge of the cellwidthPx- Image width in pixelsheightPx- Image height in pixels- Returns:
- A new PictureAnchor configured for one-cell anchoring with offset
-
twoCellAnchor
public static PictureAnchor twoCellAnchor(int fromRow, int fromCol, int toRow, int toCol)
Create a two-cell anchor spanning from one cell to another.- Parameters:
fromRow- Starting row (zero-based)fromCol- Starting column (zero-based)toRow- Ending row (zero-based, exclusive - image ends at top of this row)toCol- Ending column (zero-based, exclusive - image ends at left of this column)- Returns:
- A new PictureAnchor configured for two-cell anchoring
-
twoCellAnchor
public static PictureAnchor twoCellAnchor(int fromRow, int fromCol, int fromColOffPx, int fromRowOffPx, int toRow, int toCol, int toColOffPx, int toRowOffPx)
Create a two-cell anchor with offsets.- Parameters:
fromRow- Starting row (zero-based)fromCol- Starting column (zero-based)fromColOffPx- Starting column offset in pixelsfromRowOffPx- Starting row offset in pixelstoRow- Ending row (zero-based)toCol- Ending column (zero-based)toColOffPx- Ending column offset in pixelstoRowOffPx- Ending row offset in pixels- Returns:
- A new PictureAnchor configured for two-cell anchoring with offsets
-
isTwoCellAnchor
public boolean isTwoCellAnchor()
Check if this anchor is a two-cell anchor.- Returns:
- true if two-cell anchor, false if one-cell anchor
-
getWidthEmu
public Long getWidthEmu()
Get width in EMUs (for one-cell anchors).
-
getHeightEmu
public Long getHeightEmu()
Get height in EMUs (for one-cell anchors).
-
-