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
add(Object o)
public int add(Object o)
Adds an item to the CollectionBase instance.
Parameters:
Parameter | Type | Description |
---|---|---|
o | java.lang.Object | The 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:
Parameter | Type | Description |
---|---|---|
type | int | ControlType. The type of the control. |
topRow | int | Upper left row index. |
top | int | Represents the vertical offset of Shape from its left row, in unit of pixel. |
leftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Shape from its left column, in unit of pixel. |
width | int | Represents the width of Shape, in unit of pixel. |
height | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of ArcShape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of ArcShape from its left column, in unit of pixel. |
height | int | Represents the height of ArcShape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
type | int | AutoShapeType. Auto shape type. |
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Shape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Shape from its left column, in unit of pixel. |
height | int | Represents the height of Shape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
type | int | AutoShapeType. Auto shape type. |
top | int | Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area. |
left | int | Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area. |
height | int | Represents the height of textbox, in units of 1/4000 of the chart area. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Button from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Button from its left column, in unit of pixel. |
height | int | Represents the height of Button, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of checkbox from its top row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of textbox from its left column, in unit of pixel. |
height | int | Height of textbox, in unit of pixel. |
width | int | Width 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of ComboBox from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of ComboBox from its left column, in unit of pixel. |
height | int | Represents the height of ComboBox, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
sourceShape | Shape | Source shape. |
topRow | int | The top row index. |
top | int | Represents the vertical offset from its top row, in unit of pixel. |
leftColumn | int | The left column index. |
left | int | Represents 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:
Parameter | Type | Description |
---|---|---|
topRow | int | The top row index. |
top | int | The vertical offset its top row, in unit of pixel. |
leftColumn | int | The left column index. |
left | int | The horizontal offset from its left column, in unit of pixel. |
height | int | The height of equation, in unit of pixel. |
width | int | The 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:
Parameter | Type | Description |
---|---|---|
type | int | MsoDrawingType. The shape type. |
top | int | Represents the vertical offset of shape from the worksheet’s top row, in unit of pixel. |
left | int | Represents the horizontal offset of shape from the worksheet’s left column, in unit of pixel. |
height | int | Represents the height of LineShape, in unit of pixel. |
width | int | Represents the width of LineShape, in unit of pixel. |
imageData | byte[] | The image data,only applies for the picture. |
isOriginalSize | boolean | Whether 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Polygon from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Polygon from its left column, in unit of pixel. |
height | int | Represents the height of Polygon, in unit of pixel. |
width | int | Represents the width of Polygon, in unit of pixel. |
paths | ShapePath[] | 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of GroupBox from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of GroupBox from its left column, in unit of pixel. |
height | int | Represents the height of GroupBox, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of shape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | The horizontal offset of shape from its left column, in unit of pixel. |
height | int | The height of shape, in unit of pixel. |
width | int | The width of shape, in unit of pixel. |
imageByteData | byte[] | The image byte data. |
compatibleImageData | byte[] | 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Label from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Label from its left column, in unit of pixel. |
height | int | Represents the height of Label, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
top | int | Represents the vertical offset of label from the upper left corner in units of 1/4000 of the chart area. |
left | int | Represents the vertical offset of label from the upper left corner in units of 1/4000 of the chart area. |
height | int | Represents the height of label, in units of 1/4000 of the chart area. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of LineShape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of LineShape from its left column, in unit of pixel. |
height | int | Represents the height of LineShape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
upperLeftColumn | int | Upper left column index. |
height | int | The height of the shape. In unit of pixels |
width | int | The width of the shape. In unit of pixels |
sourceFullName | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of ListBox from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of ListBox from its left column, in unit of pixel. |
height | int | Represents the height of ListBox, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | |
top | int | |
upperLeftColumn | int | |
left | int | |
height | int | |
width | int | |
imageData | byte[] |
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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
upperLeftColumn | int | Upper left column index. |
height | int | The height of the shape. In unit of pixels |
width | int | The width of the shape. In unit of pixels |
sourceFullName | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Oval from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Oval from its left column, in unit of pixel. |
height | int | Represents the height of Oval, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
upperLeftColumn | int | Upper left column index. |
lowerRightRow | int | Lower right row index |
lowerRightColumn | int | Lower right column index |
stream | java.io.InputStream | Stream 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
upperLeftColumn | int | Upper left column index. |
stream | java.io.InputStream | Stream object which contains the image data. |
widthScale | int | Scale of image width, a percentage. |
heightScale | int | Scale 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:
Parameter | Type | Description |
---|---|---|
top | int | Represents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area. |
left | int | Represents the horizontal offset of shape from the upper left corner in units of 1/4000 of the chart area. |
stream | java.io.InputStream | Stream object which contains the image data. |
widthScale | int | Scale of image width, a percentage. |
heightScale | int | Scale 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of RadioButton from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of RadioButton from its left column, in unit of pixel. |
height | int | Represents the height of RadioButton, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of RectangleShape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of RectangleShape from its left column, in unit of pixel. |
height | int | Represents the height of RectangleShape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of ScrollBar from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of ScrollBar from its left column, in unit of pixel. |
height | int | Represents the height of ScrollBar, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
type | int | MsoDrawingType. Mso drawing type. |
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Shape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Shape from its left column, in unit of pixel. |
height | int | Represents the height of Shape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
type | int | MsoDrawingType. The drawing type. |
placement | int | PlacementType. the placement type. |
left | int | In unit of 1/4000 chart area width. |
top | int | In unit of 1/4000 chart area height. |
right | int | In unit of 1/4000 chart area width. |
bottom | int | In 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:
Parameter | Type | Description |
---|---|---|
type | int | MsoDrawingType. The drawing type. |
placement | int | PlacementType. the placement type. |
left | int | In unit of 1/4000 chart area width. |
top | int | In unit of 1/4000 chart area height. |
right | int | In unit of 1/4000 chart area width. |
bottom | int | In unit of 1/4000 chart area height. |
imageData | byte[] | 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:
Parameter | Type | Description |
---|---|---|
type | int | MsoDrawingType. The drawing type. |
placement | int | PlacementType. the placement type. |
left | double | Unit is percent scale of chart area width. |
top | double | Unit is percent scale of chart area height. |
right | double | Unit is percent scale of chart area width. |
bottom | double | Unit 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:
Parameter | Type | Description |
---|---|---|
type | int | MsoDrawingType. The drawing type. |
placement | int | PlacementType. the placement type. |
left | double | Unit is percent scale of chart area width. |
top | double | Unit is percent scale of chart area height. |
right | double | Unit is percent scale of chart area width. |
bottom | double | Unit is percent scale of chart area height. |
imageData | byte[] | 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
upperLeftColumn | int | Upper left column index. |
signatureLine | SignatureLine | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of Spinner from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of Spinner from its left column, in unit of pixel. |
height | int | Represents the height of Spinner, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of shape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | The horizontal offset of shape from its left column, in unit of pixel. |
height | int | The height of shape, in unit of pixel. |
width | int | The width of shape, in unit of pixel. |
svgData | byte[] | The svg image data. |
compatibleImageData | byte[] | 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:
Parameter | Type | Description |
---|---|---|
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of textbox from its top row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of textbox from its left column, in unit of pixel. |
height | int | Represents the height of textbox, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
top | int | Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area. |
left | int | Represents the vertical offset of textbox from the upper left corner in units of 1/4000 of the chart area. |
height | int | Represents the height of textbox, in units of 1/4000 of the chart area. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
effect | int | MsoPresetTextEffect. The mso preset text effect type. |
text | java.lang.String | The WordArt text. |
fontName | java.lang.String | The font name. |
size | int | The font size |
fontBold | boolean | Indicates whether font is bold. |
fontItalic | boolean | Indicates whether font is italic. |
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of shape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of shape from its left column, in unit of pixel. |
height | int | Represents the height of shape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
effect | int | MsoPresetTextEffect. The mso preset text effect type. |
text | java.lang.String | The WordArt text. |
fontName | java.lang.String | The font name. |
size | int | The font size |
fontBold | boolean | Indicates whether font is bold. |
fontItalic | boolean | Indicates whether font is italic. |
top | int | Represents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area. |
left | int | Represents the vertical offset of shape from the upper left corner in units of 1/4000 of the chart area. |
height | int | Represents the height of shape, in units of 1/4000 of the chart area. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
style | int | PresetWordArtStyle. The preset WordArt Style. |
text | java.lang.String | The text. |
upperLeftRow | int | Upper left row index. |
top | int | Represents the vertical offset of shape from its left row, in unit of pixel. |
upperLeftColumn | int | Upper left column index. |
left | int | Represents the horizontal offset of shape from its left column, in unit of pixel. |
height | int | Represents the height of shape, in unit of pixel. |
width | int | Represents 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:
Parameter | Type | Description |
---|---|---|
o | java.lang.Object | test 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:
Parameter | Type | Description |
---|---|---|
shapes | ShapeCollection | The source shapes. |
ca | CellArea | The source range. |
destRow | int | The dest range start row. |
destColumn | int | The 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:
Parameter | Type | Description |
---|---|---|
sourceShapes | ShapeCollection | Source shapes. |
ca | CellArea | The source range. |
destRow | int | The dest row index of the dest range. |
destColumn | int | The dest column of the dest range. |
isContained | boolean | 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. |
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:
Parameter | Type | Description |
---|---|---|
ca | CellArea | The 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:
Parameter | Type | Description |
---|---|---|
shape | Shape |
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.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:
Parameter | Type | Description |
---|---|---|
index | int | The 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:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
groupItems | Shape[] | 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:
Parameter | Type | Description |
---|---|---|
o | java.lang.Object | Determines 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:
Parameter | Type | Description |
---|---|---|
shape | Shape |
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:
Parameter | Type | Description |
---|---|---|
index | int | The 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:
Parameter | Type | Description |
---|---|---|
group | GroupShape | The 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:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |