public class ShapeCollection extends CollectionBase
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//get ShapeCollection
ShapeCollection shapes = workbook.getWorksheets().get(0).getShapes();
//do your business
//Save the excel file.
workbook.save("result.xlsx");
| Modifier and Type | Method and Description |
|---|---|
Shape |
addActiveXControl(int type,
int topRow,
int top,
int leftColumn,
int left,
int width,
int height)
Creates an Activex Control.
|
ArcShape |
addArc(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a ArcShape to the worksheet.
|
Shape |
addAutoShape(int type,
int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a AutoShape to the worksheet.
|
Shape |
addAutoShapeInChart(int type,
int top,
int left,
int height,
int width)
Adds a AutoShape to the chart.
|
Button |
addButton(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a Button to the worksheet.
|
CheckBox |
addCheckBox(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a checkbox to the worksheet.
|
ComboBox |
addComboBox(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a ComboBox to the worksheet.
|
Shape |
addCopy(Shape sourceShape,
int topRow,
int top,
int leftColumn,
int left)
Adds and copy a shape to the worksheet.
|
TextBox |
addEquation(int topRow,
int top,
int leftColumn,
int left,
int height,
int width)
Add an equation object to the worksheet.
|
Shape |
addFreeFloatingShape(int type,
int top,
int left,
int height,
int width,
byte[] imageData,
boolean isOriginalSize)
Adds a free floating shape to the worksheet.Only applies for line/image shape.
|
Shape |
addFreeform(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width,
ShapePath[] paths)
Adds a freeform shape to the worksheet.
|
GroupBox |
addGroupBox(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a GroupBox to the worksheet.
|
Picture |
addIcons(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width,
byte[] imageByteData,
byte[] compatibleImageData)
Adds svg image.
|
Label |
addLabel(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a Label to the worksheet.
|
Label |
addLabelInChart(int top,
int left,
int height,
int width)
Adds a label to the chart.
|
LineShape |
addLine(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a LineShape to the worksheet.
|
Picture |
addLinkedPicture(int upperLeftRow,
int upperLeftColumn,
int height,
int width,
java.lang.String sourceFullName)
Add a linked picture.
|
ListBox |
addListBox(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a ListBox to the worksheet.
|
OleObject |
addOleObject(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width,
byte[] imageData)
Adds an OleObject.
|
OleObject |
addOleObjectWithLinkedImage(int upperLeftRow,
int upperLeftColumn,
int height,
int width,
java.lang.String sourceFullName)
Add a linked picture.
|
Oval |
addOval(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a Oval to the worksheet.
|
Picture |
addPicture(int upperLeftRow,
int upperLeftColumn,
java.io.InputStream stream,
int widthScale,
int heightScale)
Adds a picture to the collection.
|
Picture |
addPicture(int upperLeftRow,
int upperLeftColumn,
int lowerRightRow,
int lowerRightColumn,
java.io.InputStream stream)
Adds a picture to the collection.
|
Picture |
addPictureInChart(int top,
int left,
java.io.InputStream stream,
int widthScale,
int heightScale)
Adds a picture to the chart.
|
RadioButton |
addRadioButton(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a RadioButton to the worksheet.
|
RectangleShape |
addRectangle(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a RectangleShape to the worksheet.
|
ScrollBar |
addScrollBar(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a ScrollBar to the worksheet.
|
Shape |
addShape(int type,
int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a Shape to the worksheet.
|
Shape |
addShapeInChart(int type,
int placement,
int left,
int top,
int right,
int bottom)
Add a shape to chart .All unit is 1/4000 of chart area.
|
Shape |
addShapeInChart(int type,
int placement,
int left,
int top,
int right,
int bottom,
byte[] imageData)
Add a shape to chart .All unit is 1/4000 of chart area.
|
Shape |
addShapeInChartByScale(int type,
int placement,
double left,
double top,
double right,
double bottom)
Add a shape to chart.
|
Shape |
addShapeInChartByScale(int type,
int placement,
double left,
double top,
double right,
double bottom,
byte[] imageData)
Add a shape to chart .All unit is 1/4000 of chart area.
|
Picture |
addSignatureLine(int upperLeftRow,
int upperLeftColumn,
SignatureLine signatureLine)
Adds a Signature Line to the worksheet.
|
Spinner |
addSpinner(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a Spinner to the worksheet.
|
Picture |
addSvg(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width,
byte[] svgData,
byte[] compatibleImageData)
Adds svg image.
|
TextBox |
addTextBox(int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds a text box to the worksheet.
|
TextBox |
addTextBoxInChart(int top,
int left,
int height,
int width)
Adds a textbox to the chart.
|
Shape |
addTextEffect(int effect,
java.lang.String text,
java.lang.String fontName,
int size,
boolean fontBold,
boolean fontItalic,
int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Inserts a WordArt object.
|
Shape |
addTextEffectInChart(int effect,
java.lang.String text,
java.lang.String fontName,
int size,
boolean fontBold,
boolean fontItalic,
int top,
int left,
int height,
int width)
Inserts a WordArt object to the chart
|
Shape |
addWordArt(int style,
java.lang.String text,
int upperLeftRow,
int top,
int upperLeftColumn,
int left,
int height,
int width)
Adds preset WordArt since Excel 2007.s
|
void |
clear()
Clear all shapes in the worksheet.
|
void |
copyCommentsInRange(ShapeCollection shapes,
CellArea ca,
int destRow,
int destColumn)
Copy all comments in the range.
|
void |
copyInRange(ShapeCollection sourceShapes,
CellArea ca,
int destRow,
int destColumn,
boolean isContained)
Copy shapes in the range to destination range.
|
void |
deleteInRange(CellArea ca)
Delete shapes in the range.Comment shapes will not be deleted.
|
void |
deleteShape(Shape shape)
Delete a shape.
|
Shape |
get(int index)
Gets the
Shape object at the specific index in the list. |
Shape |
get(java.lang.String name)
Gets the
Shape object by the name of the shape. |
GroupShape |
group(Shape[] groupItems)
Group the shapes.
|
void |
remove(Shape shape)
Remove the shape.
|
void |
removeAt(int index)
Remove the shape.
|
void |
ungroup(GroupShape group)
Ungroups the shape items.
|
void |
updateSelectedValue()
Update the selected value by the value of the linked cell or range of the shape.
|
public Shape get(int index)
Shape object at the specific index in the list.
Example
//get the first shape
Shape shape = shapes.get(0);
get in class CollectionBaseindex - The index.public Shape get(java.lang.String name)
Shape object by the name of the shape.
Example
//add a shape
shapes.addRectangle(2, 0, 2, 0, 130, 130);
//get the shape by the name.
Shape shape1 = shapes.get("Rectangle 1");
if(shape1 != null)
{
//Got the shape named 'Rectangle 1'.
}
name - The name of the shape.public Shape addCopy(Shape sourceShape, int topRow, int top, int leftColumn, int left)
Example
//add a shape
RectangleShape rectangle = shapes.addRectangle(2, 0, 2, 0, 130, 130);
//Adds and copies a shape.
shapes.addCopy(rectangle, 7, 0, 7, 0);
sourceShape - Source shape.topRow - The top row index.top - Represents the vertical offset from its top row, in unit of pixel.leftColumn - The left column index.left - Represents the horizontal offset from its left column, in unit of pixel.Shape object.public CheckBox addCheckBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a CheckBox
CheckBox checkBox = shapes.addCheckBox(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of checkbox from its top row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of textbox from its left column, in unit of pixel.height - Height of textbox, in unit of pixel.width - Width of textbox, in unit of pixel.public TextBox addTextBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a TextBox
TextBox textBox = shapes.addTextBox(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of textbox from its top row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of textbox from its left column, in unit of pixel.height - Represents the height of textbox, in unit of pixel.width - Represents the width of textbox, in unit of pixel.TextBox object.public TextBox addEquation(int topRow, int top, int leftColumn, int left, int height, int width)
topRow - The top row index.top - The vertical offset its top row, in unit of pixel.leftColumn - The left column index.left - The horizontal offset from its left column, in unit of pixel.height - The height of equation, in unit of pixel.width - The width of equation, in unit of pixel.public Spinner addSpinner(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a spinner
Spinner spinner = shapes.addSpinner(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of Spinner from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of Spinner from its left column, in unit of pixel.height - Represents the height of Spinner, in unit of pixel.width - Represents the width of Spinner, in unit of pixel.public ScrollBar addScrollBar(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a scroll bar
ScrollBar scrollBar = shapes.addScrollBar(1, 0, 1, 0, 100, 20);
upperLeftRow - Upper left row index.top - Represents the vertical offset of ScrollBar from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of ScrollBar from its left column, in unit of pixel.height - Represents the height of ScrollBar, in unit of pixel.width - Represents the width of ScrollBar, in unit of pixel.public RadioButton addRadioButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a radio button
RadioButton radioButton = shapes.addRadioButton(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of RadioButton from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of RadioButton from its left column, in unit of pixel.height - Represents the height of RadioButton, in unit of pixel.width - Represents the width of RadioButton, in unit of pixel.public ListBox addListBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a list box
ListBox listBox = shapes.addListBox(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of ListBox from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of ListBox from its left column, in unit of pixel.height - Represents the height of ListBox, in unit of pixel.width - Represents the width of ListBox, in unit of pixel.public ComboBox addComboBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a combo box
ComboBox comboBox = shapes.addComboBox(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of ComboBox from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of ComboBox from its left column, in unit of pixel.height - Represents the height of ComboBox, in unit of pixel.width - Represents the width of ComboBox, in unit of pixel.public GroupBox addGroupBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a group box
GroupBox groupBox = shapes.addGroupBox(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of GroupBox from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of GroupBox from its left column, in unit of pixel.height - Represents the height of GroupBox, in unit of pixel.width - Represents the width of GroupBox, in unit of pixel.public Button addButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a button
Button button = shapes.addButton(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of Button from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of Button from its left column, in unit of pixel.height - Represents the height of Button, in unit of pixel.width - Represents the width of Button, in unit of pixel.public Label addLabel(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a label
Label label = shapes.addLabel(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of Label from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of Label from its left column, in unit of pixel.height - Represents the height of Label, in unit of pixel.width - Represents the width of Label, in unit of pixel.public Label addLabelInChart(int top, int left, int height, int width)
top - Represents the vertical offset of label from the upper left corner in units of 1/4000 of the chart area.left - Represents the vertical offset of label from the upper left corner in units of 1/4000 of the chart area.height - Represents the height of label, in units of 1/4000 of the chart area.width - Represents the width of label, in units of 1/4000 of the chart area.public TextBox addTextBoxInChart(int top, int left, int height, int width)
top - Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.left - Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.height - Represents the height of textbox, in units of 1/4000 of the chart area.width - Represents the width of textbox, in units of 1/4000 of the chart area.public Shape addTextEffectInChart(int effect, java.lang.String text, java.lang.String fontName, int size, boolean fontBold, boolean fontItalic, int top, int left, int height, int width)
effect - MsoPresetTextEffect. The mso preset text effect type.text - The WordArt text.fontName - The font name.size - The font sizefontBold - Indicates whether font is bold.fontItalic - Indicates whether font is italic.top - Represents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area.left - Represents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area.height - Represents the height of shape, in units of 1/4000 of the chart area.width - Represents the width of shape, in units of 1/4000 of the chart area.public Shape addTextEffect(int effect, java.lang.String text, java.lang.String fontName, int size, boolean fontBold, boolean fontItalic, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a WordArt
Shape wordArt1 = shapes.addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_10, "WordArt", "arial", 18, false, false, 3, 0, 3, 0, 200, 50);
effect - MsoPresetTextEffect. The mso preset text effect type.text - The WordArt text.fontName - The font name.size - The font sizefontBold - Indicates whether font is bold.fontItalic - Indicates whether font is italic.upperLeftRow - Upper left row index.top - Represents the vertical offset of shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of shape from its left column, in unit of pixel.height - Represents the height of shape, in unit of pixel.width - Represents the width of shape, in unit of pixel.public Shape addWordArt(int style, java.lang.String text, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a WordArt
Shape wordArt2 = shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_1, "WordArt", 3, 0, 3, 0, 50, 200);
style - PresetWordArtStyle. The preset WordArt Style.text - The text.upperLeftRow - Upper left row index.top - Represents the vertical offset of shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of shape from its left column, in unit of pixel.height - Represents the height of shape, in unit of pixel.width - Represents the width of shape, in unit of pixel.public RectangleShape addRectangle(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
// add a rectangle
RectangleShape rectangleShape = shapes.addRectangle(2, 0, 2, 0, 130, 130);
upperLeftRow - Upper left row index.top - Represents the vertical offset of RectangleShape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of RectangleShape from its left column, in unit of pixel.height - Represents the height of RectangleShape, in unit of pixel.width - Represents the width of RectangleShape, in unit of pixel.public Oval addOval(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a oval
Oval oval = shapes.addOval(1, 0, 1, 0, 50, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of Oval from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of Oval from its left column, in unit of pixel.height - Represents the height of Oval, in unit of pixel.width - Represents the width of Oval, in unit of pixel.public LineShape addLine(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
// add a line object
LineShape lineShape = shapes.addLine(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of LineShape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of LineShape from its left column, in unit of pixel.height - Represents the height of LineShape, in unit of pixel.width - Represents the width of LineShape, in unit of pixel.public Shape addFreeFloatingShape(int type, int top, int left, int height, int width, byte[] imageData, boolean isOriginalSize)
Example
//add a line
Shape floatingShape_Line = shapes.addFreeFloatingShape(MsoDrawingType.LINE, 100, 100, 100, 50, null, false);
//add a picture
byte[] imageData = null;
FileInputStream fs = new FileInputStream("image.jpg");
try //JAVA: was using
{
int len = (int)fs.available();
imageData = new byte[len];
fs.read(imageData, 0, len);
}
finally { if (fs != null) fs.close(); }
Shape floatingShape_Picture = shapes.addFreeFloatingShape(MsoDrawingType.PICTURE, 200, 100, 100, 50, imageData, false);
type - MsoDrawingType. The shape type.top - Represents the vertical offset of shape from the worksheet's top row, in unit of pixel.left - Represents the horizontal offset of shape from the worksheet's left column, in unit of pixel.height - Represents the height of LineShape, in unit of pixel.width - Represents the width of LineShape, in unit of pixel.imageData - The image data,only applies for the picture.isOriginalSize - Whether the shape use original size if the shape is image.public Shape addShapeInChart(int type, int placement, int left, int top, int right, int bottom, byte[] imageData)
type - MsoDrawingType. The drawing type.placement - PlacementType. the placement type.left - In unit of 1/4000 chart area width.top - In unit of 1/4000 chart area height.right - In unit of 1/4000 chart area width.bottom - In unit of 1/4000 chart area height.imageData - If the shape is not a picture or ole object,imageData should be null.public Shape addShapeInChart(int type, int placement, int left, int top, int right, int bottom)
type - MsoDrawingType. The drawing type.placement - PlacementType. the placement type.left - In unit of 1/4000 chart area width.top - In unit of 1/4000 chart area height.right - In unit of 1/4000 chart area width.bottom - In unit of 1/4000 chart area height.public Shape addShapeInChartByScale(int type, int placement, double left, double top, double right, double bottom)
type - MsoDrawingType. The drawing type.placement - PlacementType. the placement type.left - Unit is percent scale of chart area width.top - Unit is percent scale of chart area height.right - Unit is percent scale of chart area width.bottom - Unit is percent scale of chart area height.public Shape addShapeInChartByScale(int type, int placement, double left, double top, double right, double bottom, byte[] imageData)
type - MsoDrawingType. The drawing type.placement - PlacementType. the placement type.left - Unit is percent scale of chart area width.top - Unit is percent scale of chart area height.right - Unit is percent scale of chart area width.bottom - Unit is percent scale of chart area height.imageData - If the shape is not a picture or ole object,imageData should be null.public ArcShape addArc(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Example
//add a arc
ArcShape arcShape = shapes.addArc(1, 0, 1, 0, 100, 50);
upperLeftRow - Upper left row index.top - Represents the vertical offset of ArcShape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of ArcShape from its left column, in unit of pixel.height - Represents the height of ArcShape, in unit of pixel.width - Represents the width of ArcShape, in unit of pixel.public Shape addShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Remarks
The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBoxExample
//Add a shape of the specified type
Shape shapeByType = shapes.addShape(MsoDrawingType.CELLS_DRAWING, 1, 0, 1, 0, 100, 50);
type - MsoDrawingType. Mso drawing type.upperLeftRow - Upper left row index.top - Represents the vertical offset of Shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of Shape from its left column, in unit of pixel.height - Represents the height of Shape, in unit of pixel.width - Represents the width of Shape, in unit of pixel.public Shape addAutoShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Remarks
The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBoxExample
//Adds a AutoShape to the worksheet.
Shape autoShape = shapes.addAutoShape(AutoShapeType.CUBE, 1, 0, 1, 0, 100, 50);
type - AutoShapeType. Auto shape type.upperLeftRow - Upper left row index.top - Represents the vertical offset of Shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of Shape from its left column, in unit of pixel.height - Represents the height of Shape, in unit of pixel.width - Represents the width of Shape, in unit of pixel.public Shape addAutoShapeInChart(int type, int top, int left, int height, int width)
Remarks
The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBoxtype - AutoShapeType. Auto shape type.top - Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.left - Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.height - Represents the height of textbox, in units of 1/4000 of the chart area.width - Represents the width of textbox, in units of 1/4000 of the chart area.public Shape addActiveXControl(int type, int topRow, int top, int leftColumn, int left, int width, int height)
Example
//add an ActiveX control
Shape activeXControl = shapes.addActiveXControl(com.aspose.cells.ControlType.CHECK_BOX, 1, 0, 1, 0, 100, 50);
type - ControlType. The type of the control.topRow - Upper left row index.top - Represents the vertical offset of Shape from its left row, in unit of pixel.leftColumn - Upper left column index.left - Represents the horizontal offset of Shape from its left column, in unit of pixel.height - Represents the height of Shape, in unit of pixel.width - Represents the width of Shape, in unit of pixel.public Picture addPicture(int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn, java.io.InputStream stream)
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.lowerRightRow - Lower right row indexlowerRightColumn - Lower right column indexstream - Stream object which contains the image data.Picture Picture object.public Picture addPicture(int upperLeftRow, int upperLeftColumn, java.io.InputStream stream, int widthScale, int heightScale)
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.stream - Stream object which contains the image data.widthScale - Scale of image width, a percentage.heightScale - Scale of image height, a percentage.Picture Picture object.public Picture addSvg(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] svgData, byte[] compatibleImageData)
Example
// add a svg
FileInputStream fs = new FileInputStream("image.svg");
try //JAVA: was using
{
int len = (int)fs.available();
byte[] imageData = new byte[len];
fs.read(imageData, 0, len);
Picture picture = shapes.addSvg(4, 0, 5, 0, -1, -1, imageData, null);
}
finally { if (fs != null) fs.close(); }
upperLeftRow - Upper left row index.top - Represents the vertical offset of shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - The horizontal offset of shape from its left column, in unit of pixel.height - The height of shape, in unit of pixel.width - The width of shape, in unit of pixel.svgData - The svg image data.compatibleImageData - Converted image data from svg in order to be compatible with Excel 2016 or lower versions.public Picture addIcons(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageByteData, byte[] compatibleImageData)
Example
//add icon
FileInputStream fs = new FileInputStream("icon.svg");
try //JAVA: was using
{
int len = (int)fs.available();
byte[] imageData = new byte[len];
fs.read(imageData, 0, len);
Picture picture = shapes.addIcons(4, 0, 5, 0, -1, -1, imageData, null);
}
finally { if (fs != null) fs.close(); }
upperLeftRow - Upper left row index.top - Represents the vertical offset of shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - The horizontal offset of shape from its left column, in unit of pixel.height - The height of shape, in unit of pixel.width - The width of shape, in unit of pixel.imageByteData - The image byte data.compatibleImageData - Converted image data from svg in order to be compatible with Excel 2016 or lower versions.public Picture addLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, java.lang.String sourceFullName)
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.height - The height of the shape. In unit of pixelswidth - The width of the shape. In unit of pixelssourceFullName - The path and name of the source file for the linked imagePicture Picture object.public OleObject addOleObjectWithLinkedImage(int upperLeftRow, int upperLeftColumn, int height, int width, java.lang.String sourceFullName)
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.height - The height of the shape. In unit of pixelswidth - The width of the shape. In unit of pixelssourceFullName - The path and name of the source file for the linked imagePicture Picture object.public Picture addPictureInChart(int top, int left, java.io.InputStream stream, int widthScale, int heightScale)
top - Represents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area.left - Represents the horizontal offset of shape from the upper left corner in units of 1/4000 of the chart area.stream - Stream object which contains the image data.widthScale - Scale of image width, a percentage.heightScale - Scale of image height, a percentage.public OleObject addOleObject(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageData)
Example
FileInputStream fs = new FileInputStream("image.jpg");
try //JAVA: was using
{
int len = (int)fs.available();
byte[] imageData = new byte[len];
fs.read(imageData, 0, len);
OleObject oleObject = shapes.addOleObject(4, 0, 5, 0, 300, 500, imageData);
}
finally { if (fs != null) fs.close(); }
upperLeftRow - top - upperLeftColumn - left - height - width - imageData - public void copyCommentsInRange(ShapeCollection shapes, CellArea ca, int destRow, int destColumn)
Example
CommentCollection comments = workbook.getWorksheets().get(0).getComments();
//Add comment to cell A1
int commentIndex = comments.add(0, 0);
Comment comment = comments.get(commentIndex);
comment.setNote("First note.");
comment.getFont().setName("Times New Roman");
//Add comment to cell B2
comments.add("B2");
comment = comments.get("B2");
comment.setNote("Second note.");
CellArea area1 = new CellArea();
area1.StartColumn = 1;
area1.StartRow = 1;
area1.EndColumn = 5;
area1.EndRow = 4;
//copy
shapes.copyCommentsInRange(shapes, area1, 5, 1);
shapes - The source shapes.ca - The source range.destRow - The dest range start row.destColumn - The dest range start column.public void copyInRange(ShapeCollection sourceShapes, CellArea ca, int destRow, int destColumn, boolean isContained)
Example
//add a shape
shapes.addRectangle(2, 0, 2, 0, 130, 130);
CellArea area2 = new CellArea();
area2.StartColumn = 1;
area2.StartRow = 1;
area2.EndColumn = 5;
area2.EndRow = 11;
//copy
shapes.copyInRange(shapes, area2, 12, 1, false);
sourceShapes - Source shapes.ca - The source range.destRow - The dest row index of the dest range.destColumn - The dest column of the dest range.isContained - Whether only copy the shapes which are contained in the range.
If true,only copies the shapes in the range.
Otherwise,it works as MS Office.public void deleteInRange(CellArea ca)
Example
//add first shape
shapes.addRectangle(2, 0, 2, 0, 50, 50);
//add second shape
shapes.addRectangle(6, 0, 2, 0, 30, 30);
CellArea area3 = new CellArea();
area3.StartColumn = 0;
area3.StartRow = 5;
area3.EndColumn = 5;
area3.EndRow = 8;
//del
shapes.deleteInRange(area3);
ca - The range.If the shapes are contained in the range, they will be removed.public void deleteShape(Shape shape)
Example
//add first shape
Shape firstShape = shapes.addRectangle(2, 0, 2, 0, 50, 50);
//add second shape
Shape secondShape = shapes.addRectangle(6, 0, 2, 0, 30, 30);
//del
shapes.deleteShape(firstShape);
shape - public GroupShape group(Shape[] groupItems)
Remarks
The shape in the groupItems should not be grouped. The shape must be in this Shapes collection.Example
//add first shape
shapes.addRectangle(2, 0, 2, 0, 50, 50);
//add second shape
shapes.addRectangle(6, 0, 2, 0, 30, 30);
Shape[] shapesArr = new Shape[] { shapes.get(0), shapes.get(1) };
GroupShape groupShape = shapes.group(shapesArr);
groupItems - the group items.public void ungroup(GroupShape group)
Remarks
If the group shape is grouped by another group shape,nothing will be done.Example
//add first shape
shapes.addRectangle(2, 0, 2, 0, 50, 50);
//add second shape
shapes.addRectangle(6, 0, 2, 0, 30, 30);
//group
Shape[] shapesArr = new Shape[] { shapes.get(0), shapes.get(1) };
GroupShape groupShape = shapes.group(shapesArr);
//ungroup
shapes.ungroup(groupShape);
group - The group shape.public void removeAt(int index)
Example
//add first shape
shapes.addRectangle(2, 0, 2, 0, 50, 50);
//add second shape
shapes.addRectangle(6, 0, 2, 0, 30, 30);
//remove
shapes.removeAt(0);
removeAt in class CollectionBaseindex - The index of the shape.public void remove(Shape shape)
Example
//add first shape
shapes.addRectangle(2, 0, 2, 0, 50, 50);
//add second shape
shapes.addRectangle(6, 0, 2, 0, 30, 30);
//get the shape
Shape s = shapes.get("Rectangle 1");// or shapes[0];
if (s != null)
{
//remove
shapes.remove(s);
}
shape - public void clear()
Example
if (shapes.getCount() > 0)
{
shapes.clear();
}
clear in class CollectionBasepublic void updateSelectedValue()
public Shape addFreeform(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, ShapePath[] paths)
Remarks
Notice: That the width and height in the parameters can be any positive integer values, not the total width and height of the ShapePath array specified by 鈥檖aths'. The relationship between them is a scale-fill relationship, that is, each ShapePath object will be scaled according to the width and height. Therefore, when there are multiple objects in the 'paths', each ShapePath object needs to be designed reasonably to meet expectations. When there is only one ShapePath object and there are no other requirements, passing the object's width and height as parameter values 鈥嬧€媔s a good solution.Example
//Custom figure
ShapePath shapePath = new ShapePath();
shapePath.moveTo(60, 45);
shapePath.arcTo(25, 25, 0, 270);
shapePath.close();
shapePath.moveTo(60, 20);
shapePath.lineTo(110, 70);
shapePath.lineTo(125, 155.5f);
shapePath.arcTo(35.5f, 35.5f, 0, 270);
shapePath.close();
shapePath.moveTo(150, 45);
shapePath.arcTo(25, 25, 0, 270);
int shapePathW = shapePath.getWidthPixel();
int shapePathH = shapePath.getHeightPixel();
ShapePath shapePath1 = new ShapePath();
shapePath1.moveTo(0, 0);
shapePath1.cubicBezierTo(48.24997f, 0.6844f,
96.5f, -7.148871f,
130, 11.517795f);
shapePath1.cubicBezierTo(163.5f, 30.18446f,
182.24997f, 75.351f,
201, 120.517795f);
shapePath1.moveTo(150, 80);
shapePath1.arcTo(25, 25, 0, 270);
if (shapePath1.getWidthPixel() > shapePathW)
{
shapePathW = shapePath1.getWidthPixel();
}
if (shapePath1.getHeightPixel() > shapePathH)
{
shapePathH = shapePath1.getHeightPixel();
}
//Notice: shapePathH and shapePathH can be any positive integer values, here we just simply set them.
//Insert custom figure into worksheet
shapes.addFreeform(1, 0, 1, 0, shapePathH, shapePathW, new ShapePath[] { shapePath, shapePath1});
upperLeftRow - Upper left row index.top - Represents the vertical offset of freeform shape from its left row, in unit of pixel.upperLeftColumn - Upper left column index.left - Represents the horizontal offset of freeform shape from its left column, in unit of pixel.height - Represents the height of freeform shape, in unit of pixel.width - Represents the width of freeform shape, in unit of pixel.paths - Represents a user-defined pathpublic Picture addSignatureLine(int upperLeftRow, int upperLeftColumn, SignatureLine signatureLine)
Example
SignatureLine wSignatureLine = new SignatureLine();
wSignatureLine.setAllowComments(true);
wSignatureLine.setEmail("example@example.com");
wSignatureLine.setInstructions("Sign to confirm the excel content.");
wSignatureLine.setLine(true);
wSignatureLine.setShowSignedDate(true);
wSignatureLine.setSigner("User");
wSignatureLine.setTitle("tester");
//wSignatureLine.SignatureLineType = SignatureType.Stamp;
Picture signatureLine1 = shapes.addSignatureLine(0, 0, wSignatureLine);
upperLeftRow - Upper left row index.upperLeftColumn - Upper left column index.signatureLine - Represents a signature line object.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.