ShapeCollection

Inheritance: java.lang.Object, com.aspose.cells.CollectionBase

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");

Methods

MethodDescription
add(Object o)Adds an item to the CollectionBase instance.
addActiveXControl(int type, int topRow, int top, int leftColumn, int left, int width, int height)Creates an Activex Control.
addArc(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a ArcShape to the worksheet.
addAutoShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a AutoShape to the worksheet.
addAutoShapeInChart(int type, int top, int left, int height, int width)Adds a AutoShape to the chart.
addButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a Button to the worksheet.
addCheckBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a checkbox to the worksheet.
addComboBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a ComboBox to the worksheet.
addCopy(Shape sourceShape, int topRow, int top, int leftColumn, int left)Adds and copy a shape to the worksheet.
addEquation(int topRow, int top, int leftColumn, int left, int height, int width)Add an equation object to the worksheet.
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.
addFreeform(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, ShapePath[] paths)Adds a freeform shape to the worksheet.
addGroupBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a GroupBox to the worksheet.
addIcons(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageByteData, byte[] compatibleImageData)Adds svg image.
addLabel(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a Label to the worksheet.
addLabelInChart(int top, int left, int height, int width)Adds a label to the chart.
addLine(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a LineShape to the worksheet.
addLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, String sourceFullName)Add a linked picture.
addListBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a ListBox to the worksheet.
addOleObject(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageData)Adds an OleObject.
addOleObjectWithLinkedImage(int upperLeftRow, int upperLeftColumn, int height, int width, String sourceFullName)Add a linked picture.
addOval(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a Oval to the worksheet.
addPicture(int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn, InputStream stream)Adds a picture to the collection.
addPicture(int upperLeftRow, int upperLeftColumn, InputStream stream, int widthScale, int heightScale)Adds a picture to the collection.
addPictureInChart(int top, int left, InputStream stream, int widthScale, int heightScale)Adds a picture to the chart.
addRadioButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a RadioButton to the worksheet.
addRectangle(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a RectangleShape to the worksheet.
addScrollBar(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a ScrollBar to the worksheet.
addShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a Shape to the worksheet.
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.
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.
addShapeInChartByScale(int type, int placement, double left, double top, double right, double bottom)Add a shape to chart.
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.
addSignatureLine(int upperLeftRow, int upperLeftColumn, SignatureLine signatureLine)Adds a Signature Line to the worksheet.
addSpinner(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a Spinner to the worksheet.
addSvg(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] svgData, byte[] compatibleImageData)Adds svg image.
addTextBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds a text box to the worksheet.
addTextBoxInChart(int top, int left, int height, int width)Adds a textbox to the chart.
addTextEffect(int effect, String text, String fontName, int size, boolean fontBold, boolean fontItalic, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Inserts a WordArt object.
addTextEffectInChart(int effect, String text, String fontName, int size, boolean fontBold, boolean fontItalic, int top, int left, int height, int width)Inserts a WordArt object to the chart
addWordArt(int style, String text, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)Adds preset WordArt since Excel 2007.s
clear()Clear all shapes in the worksheet.
contains(Object o)Return whether instance contains this object
copyCommentsInRange(ShapeCollection shapes, CellArea ca, int destRow, int destColumn)Copy all comments in the range.
copyInRange(ShapeCollection sourceShapes, CellArea ca, int destRow, int destColumn, boolean isContained)Copy shapes in the range to destination range.
deleteInRange(CellArea ca)Delete shapes in the range.Comment shapes will not be deleted.
deleteShape(Shape shape)Delete a shape.
equals(Object arg0)
get(int index)Gets the Shape object at the specific index in the list.
get(String name)Gets the Shape object by the name of the shape.
getClass()
getCount()Gets the number of elements contained in the CollectionBase instance.
group(Shape[] groupItems)Group the shapes.
hashCode()
indexOf(Object o)Determines the index of a specific item in the CollectionBase instance.
iterator()Returns an enumerator that iterates through the CollectionBase instance.
notify()
notifyAll()
remove(Shape shape)Remove the shape.
removeAt(int index)Remove the shape.
toString()
ungroup(GroupShape group)Ungroups the shape items.
updateSelectedValue()Update the selected value by the value of the linked cell or range of the shape.
wait()
wait(long arg0)
wait(long arg0, int arg1)

add(Object o)

public int add(Object o)

Adds an item to the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectThe Object to add to the CollectionBase instance.

Returns: int - The position into which the new element was inserted.

addActiveXControl(int type, int topRow, int top, int leftColumn, int left, int width, int height)

public Shape addActiveXControl(int type, int topRow, int top, int leftColumn, int left, int width, int height)

Creates an Activex Control.

Example

         //add an ActiveX control
         Shape activeXControl = shapes.addActiveXControl(com.aspose.cells.ControlType.CHECK_BOX, 1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
typeintControlType. The type of the control.
topRowintUpper left row index.
topintRepresents the vertical offset of Shape from its left row, in unit of pixel.
leftColumnintUpper left column index.
leftintRepresents the horizontal offset of Shape from its left column, in unit of pixel.
widthintRepresents the width of Shape, in unit of pixel.
heightintRepresents the height of Shape, in unit of pixel.

Returns: Shape -

addArc(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public ArcShape addArc(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a ArcShape to the worksheet.

Example

         //add a arc
         ArcShape arcShape = shapes.addArc(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of ArcShape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of ArcShape from its left column, in unit of pixel.
heightintRepresents the height of ArcShape, in unit of pixel.
widthintRepresents the width of ArcShape, in unit of pixel.

Returns: ArcShape - A ArcShape object.

addAutoShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Shape addAutoShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a AutoShape to the worksheet.

Remarks

The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBox

Example

         //Adds a AutoShape to the worksheet.
         Shape autoShape = shapes.addAutoShape(AutoShapeType.CUBE, 1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
typeintAutoShapeType. Auto shape type.
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Shape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Shape from its left column, in unit of pixel.
heightintRepresents the height of Shape, in unit of pixel.
widthintRepresents the width of Shape, in unit of pixel.

Returns: Shape - A Shape object.

addAutoShapeInChart(int type, int top, int left, int height, int width)

public Shape addAutoShapeInChart(int type, int top, int left, int height, int width)

Adds a AutoShape to the chart.

Remarks

The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBox

Parameters:

ParameterTypeDescription
typeintAutoShapeType. Auto shape type.
topintRepresents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.
leftintRepresents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.
heightintRepresents the height of textbox, in units of 1/4000 of the chart area.
widthintRepresents the width of textbox, in units of 1/4000 of the chart area.

Returns: Shape - Returns a shape object.

addButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Button addButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a Button to the worksheet.

Example

         //add a button
         Button button = shapes.addButton(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Button from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Button from its left column, in unit of pixel.
heightintRepresents the height of Button, in unit of pixel.
widthintRepresents the width of Button, in unit of pixel.

Returns: Button - A Button object.

addCheckBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public CheckBox addCheckBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a checkbox to the worksheet.

Example

         //add a CheckBox
         CheckBox checkBox = shapes.addCheckBox(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of checkbox from its top row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of textbox from its left column, in unit of pixel.
heightintHeight of textbox, in unit of pixel.
widthintWidth of textbox, in unit of pixel.

Returns: CheckBox - The new CheckBox object index.

addComboBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public ComboBox addComboBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a ComboBox to the worksheet.

Example

         //add a combo box
         ComboBox comboBox = shapes.addComboBox(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of ComboBox from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of ComboBox from its left column, in unit of pixel.
heightintRepresents the height of ComboBox, in unit of pixel.
widthintRepresents the width of ComboBox, in unit of pixel.

Returns: ComboBox - A ComboBox object.

addCopy(Shape sourceShape, int topRow, int top, int leftColumn, int left)

public Shape addCopy(Shape sourceShape, int topRow, int top, int leftColumn, int left)

Adds and copy a shape to the worksheet.

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);

Parameters:

ParameterTypeDescription
sourceShapeShapeSource shape.
topRowintThe top row index.
topintRepresents the vertical offset from its top row, in unit of pixel.
leftColumnintThe left column index.
leftintRepresents the horizontal offset from its left column, in unit of pixel.

Returns: Shape - The new Shape object.

addEquation(int topRow, int top, int leftColumn, int left, int height, int width)

public TextBox addEquation(int topRow, int top, int leftColumn, int left, int height, int width)

Add an equation object to the worksheet.

Parameters:

ParameterTypeDescription
topRowintThe top row index.
topintThe vertical offset its top row, in unit of pixel.
leftColumnintThe left column index.
leftintThe horizontal offset from its left column, in unit of pixel.
heightintThe height of equation, in unit of pixel.
widthintThe width of equation, in unit of pixel.

Returns: TextBox -

addFreeFloatingShape(int type, int top, int left, int height, int width, byte[] imageData, boolean isOriginalSize)

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.

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);

Parameters:

ParameterTypeDescription
typeintMsoDrawingType. The shape type.
topintRepresents the vertical offset of shape from the worksheet’s top row, in unit of pixel.
leftintRepresents the horizontal offset of shape from the worksheet’s left column, in unit of pixel.
heightintRepresents the height of LineShape, in unit of pixel.
widthintRepresents the width of LineShape, in unit of pixel.
imageDatabyte[]The image data,only applies for the picture.
isOriginalSizebooleanWhether the shape use original size if the shape is image.

Returns: Shape -

addFreeform(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, ShapePath[] paths)

public Shape addFreeform(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, ShapePath[] paths)

Adds a freeform shape to the worksheet.

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);
 
         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);
 
         //Insert custom figure into worksheet
         shapes.addFreeform(1, 0, 1, 0, 200, 200, new ShapePath[] { shapePath, shapePath1});

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Polygon from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Polygon from its left column, in unit of pixel.
heightintRepresents the height of Polygon, in unit of pixel.
widthintRepresents the width of Polygon, in unit of pixel.
pathsShapePath[]Represents a user-defined path

Returns: Shape - A freeform shape.

addGroupBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public GroupBox addGroupBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a GroupBox to the worksheet.

Example

         //add a group box
         GroupBox groupBox = shapes.addGroupBox(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of GroupBox from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of GroupBox from its left column, in unit of pixel.
heightintRepresents the height of GroupBox, in unit of pixel.
widthintRepresents the width of GroupBox, in unit of pixel.

Returns: GroupBox - A GroupBox object.

addIcons(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageByteData, byte[] compatibleImageData)

public Picture addIcons(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageByteData, byte[] compatibleImageData)

Adds svg image.

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(); }

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of shape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintThe horizontal offset of shape from its left column, in unit of pixel.
heightintThe height of shape, in unit of pixel.
widthintThe width of shape, in unit of pixel.
imageByteDatabyte[]The image byte data.
compatibleImageDatabyte[]Converted image data from svg in order to be compatible with Excel 2016 or lower versions.

Returns: Picture -

addLabel(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Label addLabel(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a Label to the worksheet.

Example

         //add a label
         Label label = shapes.addLabel(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Label from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Label from its left column, in unit of pixel.
heightintRepresents the height of Label, in unit of pixel.
widthintRepresents the width of Label, in unit of pixel.

Returns: Label - A Label object.

addLabelInChart(int top, int left, int height, int width)

public Label addLabelInChart(int top, int left, int height, int width)

Adds a label to the chart.

Parameters:

ParameterTypeDescription
topintRepresents the vertical offset of label from the upper left corner in units of 1/4000 of the chart area.
leftintRepresents the vertical offset of label from the upper left corner in units of 1/4000 of the chart area.
heightintRepresents the height of label, in units of 1/4000 of the chart area.
widthintRepresents the width of label, in units of 1/4000 of the chart area.

Returns: Label - A new Label object.

addLine(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public LineShape addLine(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a LineShape to the worksheet.

Example

         // add a line object
         LineShape lineShape = shapes.addLine(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of LineShape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of LineShape from its left column, in unit of pixel.
heightintRepresents the height of LineShape, in unit of pixel.
widthintRepresents the width of LineShape, in unit of pixel.

Returns: LineShape - A LineShape object.

addLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, String sourceFullName)

public Picture addLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, String sourceFullName)

Add a linked picture.

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
upperLeftColumnintUpper left column index.
heightintThe height of the shape. In unit of pixels
widthintThe width of the shape. In unit of pixels
sourceFullNamejava.lang.StringThe path and name of the source file for the linked image

Returns: Picture - Picture Picture object.

addListBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public ListBox addListBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a ListBox to the worksheet.

Example

         //add a list box
         ListBox listBox = shapes.addListBox(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of ListBox from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of ListBox from its left column, in unit of pixel.
heightintRepresents the height of ListBox, in unit of pixel.
widthintRepresents the width of ListBox, in unit of pixel.

Returns: ListBox - A ListBox object.

addOleObject(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageData)

public OleObject addOleObject(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] imageData)

Adds an OleObject.

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(); }

Parameters:

ParameterTypeDescription
upperLeftRowint
topint
upperLeftColumnint
leftint
heightint
widthint
imageDatabyte[]

Returns: OleObject -

addOleObjectWithLinkedImage(int upperLeftRow, int upperLeftColumn, int height, int width, String sourceFullName)

public OleObject addOleObjectWithLinkedImage(int upperLeftRow, int upperLeftColumn, int height, int width, String sourceFullName)

Add a linked picture.

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
upperLeftColumnintUpper left column index.
heightintThe height of the shape. In unit of pixels
widthintThe width of the shape. In unit of pixels
sourceFullNamejava.lang.StringThe path and name of the source file for the linked image

Returns: OleObject - Picture Picture object.

addOval(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Oval addOval(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a Oval to the worksheet.

Example

         //add a oval
         Oval oval = shapes.addOval(1, 0, 1, 0, 50, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Oval from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Oval from its left column, in unit of pixel.
heightintRepresents the height of Oval, in unit of pixel.
widthintRepresents the width of Oval, in unit of pixel.

Returns: Oval - A Oval object.

addPicture(int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn, InputStream stream)

public Picture addPicture(int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn, InputStream stream)

Adds a picture to the collection.

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
upperLeftColumnintUpper left column index.
lowerRightRowintLower right row index
lowerRightColumnintLower right column index
streamjava.io.InputStreamStream object which contains the image data.

Returns: Picture - Picture Picture object.

addPicture(int upperLeftRow, int upperLeftColumn, InputStream stream, int widthScale, int heightScale)

public Picture addPicture(int upperLeftRow, int upperLeftColumn, InputStream stream, int widthScale, int heightScale)

Adds a picture to the collection.

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
upperLeftColumnintUpper left column index.
streamjava.io.InputStreamStream object which contains the image data.
widthScaleintScale of image width, a percentage.
heightScaleintScale of image height, a percentage.

Returns: Picture - Picture Picture object.

addPictureInChart(int top, int left, InputStream stream, int widthScale, int heightScale)

public Picture addPictureInChart(int top, int left, InputStream stream, int widthScale, int heightScale)

Adds a picture to the chart.

Parameters:

ParameterTypeDescription
topintRepresents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area.
leftintRepresents the horizontal offset of shape from the upper left corner in units of 1/4000 of the chart area.
streamjava.io.InputStreamStream object which contains the image data.
widthScaleintScale of image width, a percentage.
heightScaleintScale of image height, a percentage.

Returns: Picture - Returns a Picture object.

addRadioButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public RadioButton addRadioButton(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a RadioButton to the worksheet.

Example

         //add a radio button
         RadioButton radioButton = shapes.addRadioButton(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of RadioButton from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of RadioButton from its left column, in unit of pixel.
heightintRepresents the height of RadioButton, in unit of pixel.
widthintRepresents the width of RadioButton, in unit of pixel.

Returns: RadioButton - A RadioButton object.

addRectangle(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public RectangleShape addRectangle(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a RectangleShape to the worksheet.

Example

         // add a rectangle
         RectangleShape rectangleShape = shapes.addRectangle(2, 0, 2, 0, 130, 130);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of RectangleShape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of RectangleShape from its left column, in unit of pixel.
heightintRepresents the height of RectangleShape, in unit of pixel.
widthintRepresents the width of RectangleShape, in unit of pixel.

Returns: RectangleShape - A RectangleShape object.

addScrollBar(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public ScrollBar addScrollBar(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a ScrollBar to the worksheet.

Example

         //add a scroll bar
         ScrollBar scrollBar = shapes.addScrollBar(1, 0, 1, 0, 100, 20);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of ScrollBar from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of ScrollBar from its left column, in unit of pixel.
heightintRepresents the height of ScrollBar, in unit of pixel.
widthintRepresents the width of ScrollBar, in unit of pixel.

Returns: ScrollBar - A ScrollBar object.

addShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Shape addShape(int type, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a Shape to the worksheet.

Remarks

The type could not be Chart/Comment/Picture/OleObject/Polygon/DialogBox

Example

         //Add a shape of the specified type
         Shape shapeByType = shapes.addShape(MsoDrawingType.CELLS_DRAWING, 1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
typeintMsoDrawingType. Mso drawing type.
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Shape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Shape from its left column, in unit of pixel.
heightintRepresents the height of Shape, in unit of pixel.
widthintRepresents the width of Shape, in unit of pixel.

Returns: Shape - A Shape object.

addShapeInChart(int type, int placement, int left, int top, int right, int bottom)

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:

ParameterTypeDescription
typeintMsoDrawingType. The drawing type.
placementintPlacementType. the placement type.
leftintIn unit of 1/4000 chart area width.
topintIn unit of 1/4000 chart area height.
rightintIn unit of 1/4000 chart area width.
bottomintIn unit of 1/4000 chart area height.

Returns: Shape

addShapeInChart(int type, int placement, int left, int top, int right, int bottom, byte[] imageData)

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:

ParameterTypeDescription
typeintMsoDrawingType. The drawing type.
placementintPlacementType. the placement type.
leftintIn unit of 1/4000 chart area width.
topintIn unit of 1/4000 chart area height.
rightintIn unit of 1/4000 chart area width.
bottomintIn unit of 1/4000 chart area height.
imageDatabyte[]If the shape is not a picture or ole object,imageData should be null.

Returns: Shape

addShapeInChartByScale(int type, int placement, double left, double top, double right, double bottom)

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:

ParameterTypeDescription
typeintMsoDrawingType. The drawing type.
placementintPlacementType. the placement type.
leftdoubleUnit is percent scale of chart area width.
topdoubleUnit is percent scale of chart area height.
rightdoubleUnit is percent scale of chart area width.
bottomdoubleUnit is percent scale of chart area height.

Returns: Shape

addShapeInChartByScale(int type, int placement, double left, double top, double right, double bottom, byte[] imageData)

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:

ParameterTypeDescription
typeintMsoDrawingType. The drawing type.
placementintPlacementType. the placement type.
leftdoubleUnit is percent scale of chart area width.
topdoubleUnit is percent scale of chart area height.
rightdoubleUnit is percent scale of chart area width.
bottomdoubleUnit is percent scale of chart area height.
imageDatabyte[]If the shape is not a picture or ole object,imageData should be null.

Returns: Shape

addSignatureLine(int upperLeftRow, int upperLeftColumn, SignatureLine signatureLine)

public Picture addSignatureLine(int upperLeftRow, int upperLeftColumn, SignatureLine signatureLine)

Adds a Signature Line to the worksheet.

Example

         SignatureLine wSignatureLine = new SignatureLine();
         wSignatureLine.setAllowComments(true);
         wSignatureLine.setEmail("dsltak@gmail.com");
         wSignatureLine.setInstructions("Sign to confirm the excel content.");
         wSignatureLine.setLine(true);
         wSignatureLine.setShowSignedDate(true);
         wSignatureLine.setSigner("TAKYU");
         wSignatureLine.setTitle("tester");
         //wSignatureLine.SignatureLineType = SignatureType.Stamp;
         Picture signatureLine1 = shapes.addSignatureLine(0, 0, wSignatureLine);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
upperLeftColumnintUpper left column index.
signatureLineSignatureLineRepresents a signature line object.

Returns: Picture -

addSpinner(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Spinner addSpinner(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a Spinner to the worksheet.

Example

         //add a spinner
         Spinner spinner = shapes.addSpinner(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of Spinner from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of Spinner from its left column, in unit of pixel.
heightintRepresents the height of Spinner, in unit of pixel.
widthintRepresents the width of Spinner, in unit of pixel.

Returns: Spinner - A Spinner object.

addSvg(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] svgData, byte[] compatibleImageData)

public Picture addSvg(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width, byte[] svgData, byte[] compatibleImageData)

Adds svg image.

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(); }

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of shape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintThe horizontal offset of shape from its left column, in unit of pixel.
heightintThe height of shape, in unit of pixel.
widthintThe width of shape, in unit of pixel.
svgDatabyte[]The svg image data.
compatibleImageDatabyte[]Converted image data from svg in order to be compatible with Excel 2016 or lower versions.

Returns: Picture -

addTextBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public TextBox addTextBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds a text box to the worksheet.

Example

         //add a TextBox
         TextBox textBox = shapes.addTextBox(1, 0, 1, 0, 100, 50);

Parameters:

ParameterTypeDescription
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of textbox from its top row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of textbox from its left column, in unit of pixel.
heightintRepresents the height of textbox, in unit of pixel.
widthintRepresents the width of textbox, in unit of pixel.

Returns: TextBox - A TextBox object.

addTextBoxInChart(int top, int left, int height, int width)

public TextBox addTextBoxInChart(int top, int left, int height, int width)

Adds a textbox to the chart.

Parameters:

ParameterTypeDescription
topintRepresents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.
leftintRepresents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area.
heightintRepresents the height of textbox, in units of 1/4000 of the chart area.
widthintRepresents the width of textbox, in units of 1/4000 of the chart area.

Returns: TextBox - A TextBox object.

addTextEffect(int effect, String text, String fontName, int size, boolean fontBold, boolean fontItalic, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Shape addTextEffect(int effect, String text, String fontName, int size, boolean fontBold, boolean fontItalic, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Inserts a 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);

Parameters:

ParameterTypeDescription
effectintMsoPresetTextEffect. The mso preset text effect type.
textjava.lang.StringThe WordArt text.
fontNamejava.lang.StringThe font name.
sizeintThe font size
fontBoldbooleanIndicates whether font is bold.
fontItalicbooleanIndicates whether font is italic.
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of shape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of shape from its left column, in unit of pixel.
heightintRepresents the height of shape, in unit of pixel.
widthintRepresents the width of shape, in unit of pixel.

Returns: Shape - Returns a Shape object that represents the new WordArt object.

addTextEffectInChart(int effect, String text, String fontName, int size, boolean fontBold, boolean fontItalic, int top, int left, int height, int width)

public Shape addTextEffectInChart(int effect, String text, String fontName, int size, boolean fontBold, boolean fontItalic, int top, int left, int height, int width)

Inserts a WordArt object to the chart

Parameters:

ParameterTypeDescription
effectintMsoPresetTextEffect. The mso preset text effect type.
textjava.lang.StringThe WordArt text.
fontNamejava.lang.StringThe font name.
sizeintThe font size
fontBoldbooleanIndicates whether font is bold.
fontItalicbooleanIndicates whether font is italic.
topintRepresents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area.
leftintRepresents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area.
heightintRepresents the height of shape, in units of 1/4000 of the chart area.
widthintRepresents the width of shape, in units of 1/4000 of the chart area.

Returns: Shape - Returns a Shape object that represents the new WordArt object.

addWordArt(int style, String text, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

public Shape addWordArt(int style, String text, int upperLeftRow, int top, int upperLeftColumn, int left, int height, int width)

Adds preset WordArt since Excel 2007.s

Example

         //add a WordArt
         Shape wordArt2 = shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_1, "WordArt", 3, 0, 3, 0, 50, 200);

Parameters:

ParameterTypeDescription
styleintPresetWordArtStyle. The preset WordArt Style.
textjava.lang.StringThe text.
upperLeftRowintUpper left row index.
topintRepresents the vertical offset of shape from its left row, in unit of pixel.
upperLeftColumnintUpper left column index.
leftintRepresents the horizontal offset of shape from its left column, in unit of pixel.
heightintRepresents the height of shape, in unit of pixel.
widthintRepresents the width of shape, in unit of pixel.

Returns: Shape -

clear()

public void clear()

Clear all shapes in the worksheet.

Example

         if (shapes.getCount() > 0)
         {
             shapes.clear();
         }

contains(Object o)

public boolean contains(Object o)

Return whether instance contains this object

Parameters:

ParameterTypeDescription
ojava.lang.Objecttest object

Returns: boolean - Whether instance contains this object

copyCommentsInRange(ShapeCollection shapes, CellArea ca, int destRow, int destColumn)

public void copyCommentsInRange(ShapeCollection shapes, CellArea ca, int destRow, int destColumn)

Copy all comments in the range.

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);

Parameters:

ParameterTypeDescription
shapesShapeCollectionThe source shapes.
caCellAreaThe source range.
destRowintThe dest range start row.
destColumnintThe dest range start column.

copyInRange(ShapeCollection sourceShapes, CellArea ca, int destRow, int destColumn, boolean isContained)

public void copyInRange(ShapeCollection sourceShapes, CellArea ca, int destRow, int destColumn, boolean isContained)

Copy shapes in the range to destination range.

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);

Parameters:

ParameterTypeDescription
sourceShapesShapeCollectionSource shapes.
caCellAreaThe source range.
destRowintThe dest row index of the dest range.
destColumnintThe dest column of the dest range.
isContainedbooleanWhether 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.

deleteInRange(CellArea ca)

public void deleteInRange(CellArea ca)

Delete shapes in the range.Comment shapes will not be deleted.

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);

Parameters:

ParameterTypeDescription
caCellAreaThe range.If the shapes are contained in the range, they will be removed.

deleteShape(Shape shape)

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.

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);

Parameters:

ParameterTypeDescription
shapeShape

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

get(int index)

public Shape get(int index)

Gets the Shape object at the specific index in the list.

Example

         //get the first shape
         Shape shape = shapes.get(0);

Parameters:

ParameterTypeDescription
indexintThe index.

Returns: Shape -

get(String name)

public Shape get(String name)

Gets the 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'.
         }

Parameters:

ParameterTypeDescription
namejava.lang.StringThe name of the shape.

Returns: Shape -

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCount()

public int getCount()

Gets the number of elements contained in the CollectionBase instance.

Returns: int - The number of elements contained in the CollectionBase instance.

group(Shape[] groupItems)

public GroupShape group(Shape[] groupItems)

Group the shapes.

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);

Parameters:

ParameterTypeDescription
groupItemsShape[]the group items.

Returns: GroupShape - Return the group shape.

hashCode()

public native int hashCode()

Returns: int

indexOf(Object o)

public int indexOf(Object o)

Determines the index of a specific item in the CollectionBase instance.

Parameters:

ParameterTypeDescription
ojava.lang.ObjectDetermines the index of a specific item in the CollectionBase instance.

Returns: int - The index of value if found in the list; otherwise, -1.

iterator()

public Iterator iterator()

Returns an enumerator that iterates through the CollectionBase instance.

Returns: java.util.Iterator - An iterator for the CollectionBase instance.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

remove(Shape shape)

public void remove(Shape shape)

Remove 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);
 
         //get the shape
         Shape s = shapes.get("Rectangle 1");// or shapes[0];
         if (s != null)
         {
             //remove 
             shapes.remove(s);
         }

Parameters:

ParameterTypeDescription
shapeShape

removeAt(int index)

public void removeAt(int index)

Remove 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);

Parameters:

ParameterTypeDescription
indexintThe index of the shape.

toString()

public String toString()

Returns: java.lang.String

ungroup(GroupShape group)

public void ungroup(GroupShape group)

Ungroups the shape items.

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);

Parameters:

ParameterTypeDescription
groupGroupShapeThe group shape.

updateSelectedValue()

public void updateSelectedValue()

Update the selected value by the value of the linked cell or range of the shape.

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int