JavaScript is disabled on your browser.
java.lang.Object
CollectionBase
com.aspose.cells.ShapeCollection
All Implemented Interfaces: java.lang.Iterable
public class ShapeCollection extends CollectionBase
Represents all the shape in a worksheet/chart.
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");
Property Getters/Setters Summary
int
getCount ()
→ inherited from com.aspose.cells.CollectionBase
Shape
get (int)
Gets the shape object at the specific index.
Shape
get (java.lang.String)
Gets the shape object by the shape image
Method Summary
int
add (java.lang.Object value)
→ inherited from com.aspose.cells.CollectionBase
Reserved for internal use.
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 upperLeftRow, int top, int upperLeftColumn, int left)
Adds and copy a shape 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.
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)
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, int lowerRightRow, int lowerRightColumn, java.io.InputStream stream)
Adds a picture to the collection.
Picture
addPicture (int upperLeftRow, int upperLeftColumn, java.io.InputStream stream, int widthScale, int heightScale)
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. All unit is percent scale of chart area.
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.
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.
boolean
contains (java.lang.Object value)
→ inherited from com.aspose.cells.CollectionBase
Reserved for internal use.
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. If the shape is in the group or is a comment shape, it will not be deleted.
GroupShape
group (com.aspose.cells.Shape[] groupItems)
Group the shapes.
int
indexOf (java.lang.Object value)
→ inherited from com.aspose.cells.CollectionBase
Reserved for internal use.
java.util.Iterator
iterator ()
→ inherited from com.aspose.cells.CollectionBase
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 of the shapes.
Property Getters/Setters Detail
getCount → inherited from com.aspose.cells.CollectionBase
public int getCount ()
get
public Shape get (int index)
Gets the shape object at the specific index.
Parameters: index
- Returns: Example:
//get the shape
Shape shape = shapes.get(shapes.getCount() -1);
get
public Shape get (java.lang.String name)
Gets the shape object by the shape image
Parameters: name
- Returns: Example:
//add a shape
shapes.addRectangle(2, 0, 2, 0, 130, 130);
//get the shape
Shape shape1 = shapes.get("Rectangle 1");
if(shape1 != null)
{
//Got the shape named 'Rectangle 1'.
}
addCopy
public Shape addCopy (Shape sourceShape, int upperLeftRow, int top, int upperLeftColumn, int left)
throws java.lang.Exception
Adds and copy a shape to the worksheet.
Parameters: sourceShape
- Source shape.upperLeftRow
- Upper left row index.top
- Represents the vertical offset of checkbox from its left 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. Returns: The new shape object index. Example:
//add a shape
RectangleShape rectangle = shapes.addRectangle(2, 0, 2, 0, 130, 130);
//copy
shapes.addCopy(rectangle, 7, 0, 7, 0);
addCheckBox
public CheckBox addCheckBox (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a checkbox to the worksheet.
Parameters: upperLeftRow
- Upper left row index.top
- Represents the vertical offset of checkbox from its left 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.Returns: The new CheckBox object index. Example:
//add a CheckBox
CheckBox checkBox = shapes.addCheckBox(1, 0, 1, 0, 100, 50);
addTextBox
public TextBox addTextBox (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a text box to the worksheet.
Parameters: upperLeftRow
- Upper left row index.top
- Represents the vertical offset of textbox from its left 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. Returns: A TextBox object. Example:
//add a TextBox
TextBox textBox = shapes.addTextBox(1, 0, 1, 0, 100, 50);
addSpinner
public Spinner addSpinner (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a Spinner to the worksheet.
Parameters: 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. Returns: A Spinner object. Example:
//add a spinner
Spinner spinner = shapes.addSpinner(1, 0, 1, 0, 100, 50);
addScrollBar
public ScrollBar addScrollBar (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a ScrollBar to the worksheet.
Parameters: 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. Returns: A ScrollBar object. Example:
//add a scroll bar
ScrollBar scrollBar = shapes.addScrollBar(1, 0, 1, 0, 100, 50);
addRadioButton
public RadioButton addRadioButton (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a RadioButton to the worksheet.
Parameters: 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. Returns: A RadioButton object. Example:
//add a radio button
RadioButton radioButton = shapes.addRadioButton(1, 0, 1, 0, 100, 50);
addListBox
public ListBox addListBox (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a ListBox to the worksheet.
Parameters: 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. Returns: A ListBox object. Example:
//add a list box
ListBox listBox = shapes.addListBox(1, 0, 1, 0, 100, 50);
addComboBox
public ComboBox addComboBox (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a ComboBox to the worksheet.
Parameters: 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. Returns: A ComboBox object. Example:
//add a combo box
ComboBox comboBox = shapes.addComboBox(1, 0, 1, 0, 100, 50);
addGroupBox
public GroupBox addGroupBox (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a GroupBox to the worksheet.
Parameters: 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. Returns: A GroupBox object. Example:
//add a group box
GroupBox groupBox = shapes.addGroupBox(1, 0, 1, 0, 100, 50);
addButton
public Button addButton (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a Button to the worksheet.
Parameters: 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. Returns: A Button object. Example:
//add a button
Button button = shapes.addButton(1, 0, 1, 0, 100, 50);
addLabel
public Label addLabel (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a Label to the worksheet.
Parameters: 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. Returns: A Label object. Example:
//add a label
Label label = shapes.addLabel(1, 0, 1, 0, 100, 50);
addLabelInChart
public Label addLabelInChart (int top, int left, int height, int width)
Adds a label to the chart.
Parameters: 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.Returns: A new Label object.
addTextBoxInChart
public TextBox addTextBoxInChart (int top, int left, int height, int width)
Adds a textbox to the chart.
Parameters: 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.Returns: A TextBox object.
addTextEffectInChart
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)
Inserts a WordArt object to the chart
Parameters: effect
- A MsoPresetTextEffect value. 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.Returns: Returns a Shape object that represents the new WordArt object.
addTextEffect
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)
Inserts a WordArt object.
Parameters: effect
- A MsoPresetTextEffect value. 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. Returns: Returns a Shape object that represents the new WordArt object. Example:
//add a WordArt
Shape wordArt1 = shapes.addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_10, "WordArt", "arial", 18, false, false, 3, 0, 3, 0, 200, 50);
addWordArt
public Shape addWordArt (int style, java.lang.String text, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
throws java.lang.Exception
Adds preset WordArt since Excel 2007.s
Parameters: style
- A PresetWordArtStyle value. 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. Returns: Example:
//add a WordArt
Shape wordArt2 = shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_1, "WordArt", 3, 0, 3, 0, 50, 200);
addRectangle
public RectangleShape addRectangle (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a RectangleShape to the worksheet.
Parameters: 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. Returns: A RectangleShape object. Example:
// add a rectangle
RectangleShape rectangleShape = shapes.addRectangle(2, 0, 2, 0, 130, 130);
addOval
public Oval addOval (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a Oval to the worksheet.
Parameters: 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. Returns: A Oval object. Example:
//add a oval
Oval oval = shapes.addOval(1, 0, 1, 0, 50, 50);
addLine
public LineShape addLine (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a LineShape to the worksheet.
Parameters: 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. Returns: A LineShape object. Example:
// add a line object
LineShape lineShape = shapes.addLine(1, 0, 1, 0, 100, 50);
addFreeFloatingShape
public 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.
Parameters: type
- A MsoDrawingType value. 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.Returns: 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);
addShapeInChart
public 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.
Parameters: type
- A MsoDrawingType value. The drawing type.placement
- A PlacementType value. 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.
addShapeInChart
public 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.
Parameters: type
- A MsoDrawingType value. The drawing type.placement
- A PlacementType value. 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.
addShapeInChartByScale
public Shape addShapeInChartByScale (int type, int placement, double left, double top, double right, double bottom)
Add a shape to chart. All unit is percent scale of chart area.
Parameters: type
- A MsoDrawingType value. The drawing type.placement
- A PlacementType value. 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.
addShapeInChartByScale
public 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.
Parameters: type
- A MsoDrawingType value. The drawing type.placement
- A PlacementType value. 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.
addArc
public ArcShape addArc (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a ArcShape to the worksheet.
Parameters: 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. Returns: A ArcShape object. Example:
//add a arc
ArcShape arcShape = shapes.addArc(1, 0, 1, 0, 100, 50);
addShape
public Shape addShape (int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a Shape to the worksheet.
The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBox Parameters: type
- A MsoDrawingType value. 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. Returns: A Shape object. Example:
//Add a shape of the specified type
Shape shapeByType = shapes.addShape(MsoDrawingType.CELLS_DRAWING, 1, 0, 1, 0, 100, 50);
addAutoShape
public Shape addAutoShape (int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)
Adds a AutoShape to the worksheet.
The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBox Parameters: type
- A AutoShapeType value. 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. Returns: A Shape object. Example:
//Adds a AutoShape to the worksheet.
Shape autoShape = shapes.addAutoShape(AutoShapeType.CUBE, 1, 0, 1, 0, 100, 50);
addAutoShapeInChart
public Shape addAutoShapeInChart (int type, int top, int left, int height, int width)
Adds a AutoShape to the chart.
The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBox Parameters: type
- A AutoShapeType value. 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.Returns: Returns a shape object.
addActiveXControl
public Shape addActiveXControl (int type, int topRow, int top, int leftColumn, int left, int width, int height)
throws java.lang.Exception
Creates an Activex Control.
Parameters: type
- A ControlType value. 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. Returns: Example:
//add an ActiveX control
Shape activeXControl = shapes.addActiveXControl(com.aspose.cells.ControlType.CHECK_BOX, 1, 0, 1, 0, 100, 50);
addPicture
public Picture addPicture (int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn, java.io.InputStream stream)
Adds a picture to the collection.
Parameters: 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.Returns: Picture Picture object.
addPicture
public Picture addPicture (int upperLeftRow, int upperLeftColumn, java.io.InputStream stream, int widthScale, int heightScale)
throws java.lang.Exception
Adds a picture to the collection.
Parameters: 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.Returns: Picture Picture object.
addSvg
public Picture addSvg (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] svgData, byte[] compatibleImageData)
throws java.lang.Exception
Adds svg image.
Parameters: 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.Returns: 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(); }
addIcons
public Picture addIcons (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageByteData, byte[] compatibleImageData)
throws java.lang.Exception
Adds svg image.
Parameters: 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.Returns: 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.addSvg(4, 0, 5, 0, -1, -1, imageData, null);
}
finally { if (fs != null) fs.close(); }
addLinkedPicture
public Picture addLinkedPicture (int upperLeftRow, int upperLeftColumn, int height, int width, java.lang.String sourceFullName)
Add a linked picture.
Parameters: 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 imageReturns: Picture Picture object.
addOleObjectWithLinkedImage
public OleObject addOleObjectWithLinkedImage (int upperLeftRow, int upperLeftColumn, int height, int width, java.lang.String sourceFullName)
Add a linked picture.
Parameters: 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 imageReturns: Picture Picture object.
addPictureInChart
public Picture addPictureInChart (int top, int left, java.io.InputStream stream, int widthScale, int heightScale)
Adds a picture to the chart.
Parameters: 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.Returns: Returns a Picture object.
addOleObject
public OleObject addOleObject (int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageData)
Parameters: upperLeftRow
- top
- upperLeftColumn
- left
- height
- width
- imageData
- Returns: 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(); }
copyCommentsInRange
public void copyCommentsInRange (ShapeCollection shapes, CellArea ca, int destRow, int destColumn)
throws java.lang.Exception
Copy all comments in the range.
Parameters: shapes
- The source shapes.ca
- The source range.destRow
- The dest range start row.destColumn
- The dest range start column.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);
copyInRange
public void copyInRange (ShapeCollection sourceShapes, CellArea ca, int destRow, int destColumn, boolean isContained)
throws java.lang.Exception
Copy shapes in the range to destination range.
Parameters: 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.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);
deleteInRange
public void deleteInRange (CellArea ca)
Delete shapes in the range.Comment shapes will not be deleted.
Parameters: ca
- The range.If the shapes are contained in the range, they will be removed.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);
deleteShape
public void deleteShape (Shape shape)
Delete a shape. If the shape is in the group or is a comment shape, it will not be deleted.
Parameters: 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);
group
public GroupShape group (com.aspose.cells.Shape[] groupItems)
Group the shapes.
The shape in the groupItems should not be grouped.
The shape must be in this Shapes collection. Parameters: groupItems
- the group items.Returns: Return the group shape. 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);
ungroup
public void ungroup (GroupShape group)
throws java.lang.Exception
Ungroups the shape items.
If the group shape is grouped by another group shape,nothing will be done. Parameters: group
- The group shape.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);
removeAt
public void removeAt (int index)
Remove the shape.
Parameters: index
- The index of the shape.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);
remove
public void remove (Shape shape)
Remove the shape.
Parameters: 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);
}
clear
public void clear ()
Clear all shapes.
Example:
if (shapes.getCount() > 0)
{
shapes.clear();
}
updateSelectedValue
public void updateSelectedValue ()
throws java.lang.Exception
Update the selected value by the value of the linked cell of the shapes.
iterator → inherited from com.aspose.cells.CollectionBase
public java.util.Iterator iterator ()
contains → inherited from com.aspose.cells.CollectionBase
public boolean contains (java.lang.Object value)
Reserved for internal use.
add → inherited from com.aspose.cells.CollectionBase
public int add (java.lang.Object value)
Reserved for internal use.
indexOf → inherited from com.aspose.cells.CollectionBase
public int indexOf (java.lang.Object value)
Reserved for internal use.
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.