[]
IShape objects on a worksheet.This interface provides access to drawing objects on the specified sheet, including shapes, charts, pictures, and connectors. It supports adding new drawing objects, retrieving individual shapes by index or name, creating shape range ( IShapeRange) subsets, and iterating through the collection.
IShapes shapes = worksheet.getShapes();
IShape titleShape = shapes.addShape(AutoShapeType.Rectangle, 20, 20, 120, 40);
titleShape.getTextFrame().getTextRange().setText("Sales");
IShape sameShape = shapes.get(0);
addCameraPicture(String reference,
double left,
double top) addCameraPicture(String reference,
double left,
double top,
double width,
double height) addCameraPicture(String reference,
IRange range) addCameraPicture(String reference,
String name,
double left,
double top) addCameraPicture(String reference,
String name,
double left,
double top,
double width,
double height) addCameraPicture(String reference,
String name,
IRange range) addChartInPixel(ChartType chartType,
double left,
double top,
double width,
double height) addChartInPixel(String name,
ChartType chartType,
double left,
double top,
double width,
double height) addConnector(ConnectorType type,
double beginX,
double beginY,
double endX,
double endY) IShape object that represents the new connector.addConnector(ConnectorType type,
IRange range) addConnector(String name,
ConnectorType type,
double beginX,
double beginY,
double endX,
double endY) IShape object that represents the new connector.addConnector(String name,
ConnectorType type,
IRange range) addConnectorInPixel(ConnectorType type,
float beginX,
float beginY,
float endX,
float endY) IShape object that represents the new connector.addConnectorInPixel(String name,
ConnectorType type,
float beginX,
float beginY,
float endX,
float endY) IShape object that represents the new connector.addPicture(InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) addPicture(InputStream stream,
ImageType type,
IRange range) addPicture(String filename,
double left,
double top,
double width,
double height) IShape object that represents the new picture.addPicture(String filename,
IRange range) addPicture(String name,
InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) addPicture(String name,
InputStream stream,
ImageType type,
IRange range) addPicture(String name,
String filename,
double left,
double top,
double width,
double height) addPicture(String name,
String filename,
IRange range) addPictureInPixel(InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) addPictureInPixel(String filename,
double left,
double top,
double width,
double height) IShape object that represents the new picture.addPictureInPixel(String name,
InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) addPictureInPixel(String name,
String filename,
double left,
double top,
double width,
double height) addShape(AutoShapeType type,
double left,
double top,
double width,
double height) IShape object.addShape(AutoShapeType type,
IRange range) IShape object that represents the new preset shape at the specified range on the current sheet.addShape(String name,
AutoShapeType type,
double left,
double top,
double width,
double height) IShape object that represents the new preset shape in a worksheet.addShape(String name,
AutoShapeType type,
IRange range) IShape object that represents the new preset shape at the specified range on the current sheet.addShapeInPixel(AutoShapeType type,
double left,
double top,
double width,
double height) addShapeInPixel(String name,
AutoShapeType type,
double left,
double top,
double width,
double height) get(int index) intgetCount()getRange(int[] index) IShapeRange) object that represents a subset of the shapes in a IShapes collection.IShapeRange) object that represents a subset of the shapes in a IShapes collection.forEach, iterator, spliteratorIShapeRange) object that represents a subset of the shapes in a IShapes collection.Use this overload to create a shape range by specifying the names of the shapes to include.
IShapes shapes = worksheet.getShapes();
IShape rectangle = shapes.addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
rectangle.setName("Rectangle 1");
IShape oval = shapes.addShape(AutoShapeType.Oval, 140, 20, 100, 60);
oval.setName("Oval 1");
IShapeRange shapeRange = shapes.getRange(new String[] {"Rectangle 1", "Oval 1"});
index - The names of the shapes to include in the returned shape range.IShapeRange object that represents the specified subset of shapes.IShapeRange) object that represents a subset of the shapes in a IShapes collection.Use this method to select multiple shapes by their index numbers and work with them as a single shape range.
IShapes shapes = worksheet.getShapes();
shapes.addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
shapes.addShape(AutoShapeType.Oval, 140, 20, 100, 60);
IShapeRange range = shapes.getRange(new int[] {0, 1});
index - The index numbers of the shapes to include in the returned shape range.IShapeRange object that contains the specified shapes.Gets the IShape at the specified index in the shapes collection.
IShapes shapes = worksheet.getShapes();
shapes.addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IShape shape = shapes.get(0);
shape.setName("Rectangle 1");
index - The zero-based index number for the object.IShape at the specified index.Gets the IShape object with the specified name from the shape collection.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.setName("SalesBox");
IShape namedShape = worksheet.getShapes().get("SalesBox");
Use this method to get the current number of IShape objects in the IShapes collection for a worksheet.
IShapes shapes = worksheet.getShapes();
shapes.addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
shapes.addShape(AutoShapeType.Oval, 140, 20, 100, 60);
int count = shapes.getCount();
Use the position and size arguments, in points, to place the chart on the worksheet. The returned IShape contains the chart and can be used to access the chart through IShape.getChart().
worksheet.getRange("A1:D5").setValue(new Object[][] {
{null, "Revenue", "Profit", "Sales"},
{"North", 10, 25, 25},
{"East", 51, 36, 27},
{"South", 52, 85, 30},
{"West", 22, 65, 65}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 200, 75, 300, 220);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D5"), RowCol.Columns, true, true);
chartType - The chart type.left - The distance, in points, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).top - The distance, in points, from the top edge of the new chart shape to the top edge of the worksheet.width - The width, in points, of the object.height - The height, in points, of the object.IShape object.The sheet of the target range and the sheet to which the shape is added must be the same sheet.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 200}
});
IRange range = worksheet.getRange("D1:J8");
IShape chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, range);
chartType - The chart type.range - The target range on the current sheet where the chart is created.IShape object that represents the new chart.Use this method to add a chart shape with an explicit name and size. The position and size are measured in points. After the chart is created, use IShape.getChart() to configure its data series and other chart settings.
worksheet.getRange("A1:D5").setValue(new Object[][] {
{null, "Revenue", "Profit", "Sales"},
{"North", 10, 25, 25},
{"East", 51, 36, 27},
{"South", 52, 85, 30},
{"West", 22, 65, 65}
});
IShape shape = worksheet.getShapes().addChart("SalesChart", ChartType.ColumnClustered, 200, 75, 300, 220);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D5"), RowCol.Columns, true, true);
name - The chart name.chartType - The chart type.left - The distance, in points, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).top - The distance, in points, from the top edge of the new chart shape to the top edge of the worksheet.width - The width, in points, of the object.height - The height, in points, of the object.IShape object that represents the new chart.The sheet of range and the sheet to which the shape is added must be the same sheet.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Region", "Sales"},
{"North", 10},
{"South", 15}
});
IRange range = worksheet.getRange("D1:H10");
IShape shape = worksheet.getShapes().addChart("SalesChart", ChartType.ColumnClustered, range);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
name - The chart name.chartType - The chart type.range - The target range on the current sheet. This range must belong to the same sheet as the shape collection.IShape object that represents the new chart.IShape object that represents the new picture. Use this method to place a picture at a specific position on the current sheet. The left and top values are measured in points relative to the upper-left corner of the document.
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IShape picture = worksheet.getShapes().addPicture(imagePath, 20, 20, 120, 80);
picture.setName("Logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture from file", e);
}
filename - The file from which the object is to be created. null is not supported.left - The position, in points, of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in points.height - The height of the picture, in points.IShape object that represents the new picture.IOException - if the specified file cannot be read.The sheet of range and the sheet that receives the new shape must be the same sheet.
Returns the IShape object that represents the new picture.
IRange range = worksheet.getRange("B2:D8");
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IShape picture = worksheet.getShapes().addPicture(imagePath, range);
picture.setAlternativeText("Product image");
filename - The file from which the picture is created.range - The target range on the current sheet.IShape object that represents the new picture.IOException - if the specified file cannot be read.The picture is positioned in points relative to the upper-left corner of the document. This method returns the IShape object that represents the new picture.
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IShape picture = worksheet.getShapes().addPicture("CompanyLogo", imagePath, 20, 20, 120, 80);
picture.setName("CompanyLogo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture by name from file", e);
}
name - The picture name.filename - The file from which the object is to be created.left - The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position (in points) of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in points.height - The height of the picture, in points.IShape object that represents the new picture.IOException - if the picture file cannot be read.The sheet of range and the sheet that receives the new shape must be the same sheet.
Returns the IShape object that represents the new picture.
IRange range = worksheet.getRange("B2:D8");
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IShape picture = worksheet.getShapes().addPicture("ProductImage", imagePath, range);
picture.setAlternativeText("Product image");
name - The picture name.filename - The file from which the picture is created.range - The target range on the current sheet.IShape object that represents the new picture.IOException - if the picture file cannot be read.Returns the IShape object that represents the new picture.
try (InputStream stream = createSampleImageStream()) {
IShape picture = worksheet.getShapes().addPicture(stream, ImageType.PNG, 20, 20, 80, 60);
picture.setName("Logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture from stream", e);
}
stream - The stream from which the object is to be created.type - Specifies the type of picture to create.left - The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position (in points) of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in points.height - The height of the picture, in points.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the stream.The sheet of targetRange and the sheet of the shape being added must be the same sheet.
Returns the IShape object that represents the new picture.
IRange range = worksheet.getRange("B2:D6");
try (InputStream stream = createSampleImageStream()) {
IShape picture = worksheet.getShapes().addPicture(stream, ImageType.PNG, range);
picture.setAlternativeText("Company logo");
}
stream - The stream from which the object is to be created.type - Specifies the type of picture to create.range - The target range of the current sheet.IShape object.IOException - if an I/O error occurs while reading the stream.Returns the IShape object that represents the new picture.
try (InputStream stream = createSampleImageStream()) {
IShape picture = worksheet.getShapes().addPicture("CompanyLogo", stream, ImageType.PNG, 20, 20, 120, 80);
picture.setAlternativeText("Company logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture by name from stream", e);
}
name - The picture name.stream - The stream from which the object is to be created.type - Specifies the type of picture to create.left - The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position (in points) of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in points.height - The height of the picture, in points.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the stream.The worksheet of range and the worksheet to which the shape is added must be the same.
Returns the IShape object that represents the new picture.
IRange range = worksheet.getRange("B2:D6");
try (InputStream stream = createSampleImageStream()) {
IShape picture = worksheet.getShapes().addPicture("CompanyLogo", stream, ImageType.PNG, range);
picture.setAlternativeText("Company logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture by name to range from stream", e);
}
name - The picture name.stream - The stream from which the picture is created.type - Specifies the type of picture to create.range - The target range on the current sheet.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the stream.IShape object.The shape is created at the specified position and size, measured in points relative to the upper-left corner of the document.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
shape.setName("SalesBox");
shape.getTextFrame().getTextRange().setText("Sales");
type - Specifies the type of preset shape to create.left - The position, in points, of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.width - The width of the preset shape's boundary box, in points.height - The height of the preset shape's boundary box, in points.IShape object.IShape object that represents the new preset shape at the specified range on the current sheet. The sheet of range and the sheet of the shape being added must be the same sheet.
IRange range = worksheet.getRange("B2:D5");
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, range);
shape.getTextFrame().getTextRange().setText("Sales");
type - Specifies the type of preset shape to create.range - The target range on the current sheet.IShape object that represents the new preset shape.IShape object that represents the new preset shape in a worksheet.Creates a preset shape with the specified name, type, position, and size. The shape name can be used to retrieve the created shape from the worksheet's shape collection.
IShape shape = worksheet.getShapes().addShape("ProcessBox", AutoShapeType.Rectangle, 50, 40, 120, 60);
shape.getTextFrame().getTextRange().setText("Review");
worksheet.getShapes().get("ProcessBox").getFill().getColor().setRGB(Color.GetBlue());
name - The shape name.type - Specifies the type of preset shape to create.left - The position, in points, of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.width - The width of the preset shape's boundary box, in points.height - The height of the preset shape's boundary box, in points.IShape object that represents the new preset shape.IShape object that represents the new preset shape at the specified range on the current sheet.The sheet of range and the sheet to which the shape is being added must be the same sheet.
IRange range = worksheet.getRange("B2:D4");
IShape shape = worksheet.getShapes().addShape("ProcessBox", AutoShapeType.Rectangle, range);
shape.getTextFrame().getTextRange().setText("Review");
name - The shape name.type - Specifies the type of preset shape to create.range - The target range on the current sheet. Must belong to the same worksheet as the shape collection; null is not supported.IShape object that represents the new preset shape.IShape object that represents the new connector.The connector's starting and end points are specified in points relative to the upper-left corner of the document.
IShape shape1 = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 80, 50);
IShape shape2 = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 180, 20, 80, 50);
IShape connector = worksheet.getShapes().addConnector(ConnectorType.Straight, 100, 45, 180, 45);
connector.getConnectorFormat().beginConnect(shape1, 3);
connector.getConnectorFormat().endConnect(shape2, 1);
type - The connector type to add.beginX - The horizontal position (in points) of the connector's starting point relative to the upper-left corner of the document.beginY - The vertical position (in points) of the connector's starting point relative to the upper-left corner of the document.endX - The horizontal position (in points) of the connector's end point relative to the upper-left corner of the document.endY - The vertical position (in points) of the connector's end point relative to the upper-left corner of the document.IShape object that represents the new connector.The sheet of range and the sheet of the shape being added must be the same sheet.
IRange range = worksheet.getRange("B12:D12");
IShape connector = worksheet.getShapes().addConnector(ConnectorType.Curve, range);
connector.setName("FlowConnector");
type - The connector type to add.range - The target range on the current sheet that defines the connector position and size.IShape object that represents the new connector.IShape object that represents the new connector.Use this method to add a connector by specifying the coordinates of its starting and end points. The coordinate values are measured in points relative to the upper-left corner of the document.
IShape startShape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 60, 40);
IShape endShape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 160, 100, 60, 40);
IShape connector = worksheet.getShapes().addConnector("Connector1", ConnectorType.Straight, 80, 40, 160, 120);
connector.getConnectorFormat().beginConnect(startShape, 3);
connector.getConnectorFormat().endConnect(endShape, 1);
name - The connector name.type - The connector type to add.beginX - The horizontal position, in points, of the connector's starting point relative to the upper-left corner of the document.beginY - The vertical position, in points, of the connector's starting point relative to the upper-left corner of the document.endX - The horizontal position, in points, of the connector's end point relative to the upper-left corner of the document.endY - The vertical position, in points, of the connector's end point relative to the upper-left corner of the document.IShape object that represents the new connector.The sheet of range and the sheet where the shape is added must be the same sheet.
Returns the IShape object that represents the new connector.
IRange range = worksheet.getRange("B2:D6");
IShape shape = worksheet.getShapes().addConnector("Connector1", ConnectorType.Elbow, range);
shape.getConnectorFormat().setType(ConnectorType.Curve);
name - The name of the connector.type - The connector type to add.range - The target range on the current sheet.IShape object that represents the new connector.This method positions the chart by using pixel-based coordinates and size values. The returned IShape represents the newly created chart shape.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IShape shape = worksheet.getShapes().addChartInPixel(ChartType.ColumnClustered, 20, 30, 320, 220);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
chartType - The chart type.left - The distance, in pixels, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).top - The distance, in pixels, from the top edge of the new chart shape to the top edge of the worksheet.width - The width, in pixels, of the object.height - The height, in pixels, of the object.IShape object.The chart position and size are measured in pixels.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IShape shape = worksheet.getShapes().addChartInPixel("SalesChart", ChartType.ColumnClustered, 20, 30, 320, 220);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
name - The chart name.chartType - The chart type.left - The distance, in pixels, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).top - The distance, in pixels, from the top edge of the new chart shape to the top edge of the worksheet.width - The width, in pixels, of the object.height - The height, in pixels, of the object.IShape object that represents the new chart.IShape object that represents the new picture. The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IShape picture = worksheet.getShapes().addPictureInPixel(imagePath, 20, 20, 120, 80);
picture.setName("Logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture in pixel from file", e);
}
filename - The file from which the picture is created.left - The position, in pixels, of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position, in pixels, of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in pixels.height - The height of the picture, in pixels.IShape object that represents the new picture.IOException - if the specified file cannot be read.IShape object that represents the new picture. Use this method to insert a picture at the specified position and size, with all coordinates and dimensions measured in pixels.
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IShape picture = worksheet.getShapes().addPictureInPixel("CompanyLogo", imagePath, 20, 20, 120, 80);
picture.setName("CompanyLogo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture in pixel by name from file", e);
}
name - The picture name.filename - The file from which the object is to be created.left - The position (in pixels) of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position (in pixels) of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in pixels.height - The height of the picture, in pixels.IShape object.IOException - if the picture file cannot be read.IShape object that represents the new picture. The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.
try (InputStream stream = createSampleImageStream()) {
IShape picture = worksheet.getShapes().addPictureInPixel(stream, ImageType.PNG, 20, 20, 120, 80);
picture.setAlternativeText("Company logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture in pixel from stream", e);
}
stream - The stream from which the object is to be created.type - Specifies the type of picture to create.left - The position (in pixels) of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position (in pixels) of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in pixels.height - The height of the picture, in pixels.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the picture stream.IShape object that represents the new picture.The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.
try (InputStream stream = createSampleImageStream()) {
IShape picture = worksheet.getShapes().addPictureInPixel("CompanyLogo", stream, ImageType.PNG, 20, 20, 120, 80);
picture.setAlternativeText("Company logo");
} catch (IOException e) {
throw new IllegalStateException("Unable to add picture in pixel by name from stream", e);
}
name - The picture name.stream - The stream from which the picture is created.type - Specifies the type of picture to create.left - The position, in pixels, of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position, in pixels, of the upper-left corner of the picture relative to the top of the document.width - The width of the picture, in pixels.height - The height of the picture, in pixels.IShape object that represents the new picture.IOException - if an I/O error occurs while reading the image stream.This method returns the IShape object that represents the new preset shape. The specified pixel values are converted to points before the shape is created.
IShape shape = worksheet.getShapes().addShapeInPixel(
AutoShapeType.Rectangle, 20, 30, 120, 60);
shape.setName("ProcessBox");
type - Specifies the type of preset shape to create. Cannot be null.left - The position (in pixels) of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.top - The position (in pixels) of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.width - The width of the preset shape's boundary box, in pixels.height - The height of the preset shape's boundary box, in pixels.IShape object that represents the new preset shape.The shape position and size are measured in pixels. The left and top values specify the position of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.
IShape shape = worksheet.getShapes().addShapeInPixel(
"ProcessBox", AutoShapeType.Rectangle, 24, 36, 160, 90);
shape.setAlternativeText("Review step");
name - The shape name.type - Specifies the type of preset shape to create.left - The position, in pixels, of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.top - The position, in pixels, of the upper-left corner of the preset shape's boundary box relative to the upper-left corner of the document.width - The width of the preset shape's boundary box, in pixels.height - The height of the preset shape's boundary box, in pixels.IShape object that represents the new preset shape.IShape object that represents the new connector.This method uses pixel-based coordinates for the connector's starting and ending points, relative to the upper-left corner of the document.
IShape shape1 = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 80, 50);
IShape shape2 = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 180, 20, 80, 50);
IShape connector = worksheet.getShapes().addConnectorInPixel(ConnectorType.Straight, 100f, 45f, 180f, 45f);
connector.getConnectorFormat().beginConnect(shape1, 3);
connector.getConnectorFormat().endConnect(shape2, 1);
type - The connector type to add.beginX - The horizontal position, in pixels, of the connector's starting point relative to the upper-left corner of the document.beginY - The vertical position, in pixels, of the connector's starting point relative to the upper-left corner of the document.endX - The horizontal position, in pixels, of the connector's end point relative to the upper-left corner of the document.endY - The vertical position, in pixels, of the connector's end point relative to the upper-left corner of the document.IShape object that represents the new connector.IShape object that represents the new connector.This method uses pixel-based coordinates for the connector's starting and ending points, relative to the upper-left corner of the document.
IShape startShape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 60, 40);
IShape endShape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 160, 100, 60, 40);
IShape connector = worksheet.getShapes().addConnectorInPixel("Connector1", ConnectorType.Straight, 80f, 40f, 160f, 120f);
connector.getConnectorFormat().beginConnect(startShape, 3);
connector.getConnectorFormat().endConnect(endShape, 1);
name - The name of the connector.type - The connector type to add.beginX - The horizontal position, in pixels, of the connector's starting point relative to the upper-left corner of the document.beginY - The vertical position, in pixels, of the connector's starting point relative to the upper-left corner of the document.endX - The horizontal position, in pixels, of the connector's end point relative to the upper-left corner of the document.endY - The vertical position, in pixels, of the connector's end point relative to the upper-left corner of the document.IShape object that represents the new connector.Returns the IShape object that represents the new picture. The left and top parameters specify the placement position in points.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
IShape picture = worksheet.getShapes().addCameraPicture("=$A$1:$B$2", 20, 20);
picture.setName("SalesSnapshot");
reference - The reference of the range used to generate the picture.left - The position, in points, of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the picture relative to the top of the document.IShape object that represents the new picture.Returns the IShape object that represents the new picture. The picture is placed at the specified position and sized using point units.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
IShape picture = worksheet.getShapes().addCameraPicture("=$A$1:$B$2", 20, 30, 160, 80);
reference - The range reference string that identifies the source range from which the picture is generated.left - The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position (in points) of the upper-left corner of the picture relative to the top of the document.width - The width of the camera picture's boundary box, in points.height - The height of the camera picture's boundary box, in points.IShape object that represents the new picture.The worksheet that contains range must be the same worksheet that owns this IShapes collection. The returned picture is positioned and sized to match the specified target range.
worksheet.getRange("A10:C20").setValue(new Object[][] {
{"Name", "Value", "Status"},
{"Item A", 100, "Open"}
});
IRange range = worksheet.getRange("E2:G6");
IShape picture = worksheet.getShapes().addCameraPicture("A10:C20", range);
reference - The reference of the source range used to generate the picture.range - The target range on the current sheet where the picture is placed.IShape object that represents the new picture.UnsupportedOperationException - if range is on a different worksheet.The returned picture is generated from the source range and remains linked to that range. Use name to assign a name to the created picture.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
IShape picture = worksheet.getShapes().addCameraPicture("=$A$1:$B$2", "SalesSnapshot", 20, 20);
picture.getPictureFormat().setTransparentBackground(true);
reference - The reference of the source range used to generate the picture.name - The name of the picture.left - The position, in points, of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the picture relative to the top of the document.IShape object that represents the new picture.The returned picture is generated from the source range and remains linked to that range. Use name to assign a name to the created picture.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
IShape picture = worksheet.getShapes().addCameraPicture("=$A$1:$B$2", "SalesSnapshot", 20, 20, 120, 60);
picture.getPictureFormat().setTransparentBackground(true);
reference - The reference of the source range used to generate the picture.name - The name of the picture.left - The position, in points, of the upper-left corner of the picture relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the picture relative to the top of the document.width - The width of the picture's boundary box, in points.height - The height of the picture's boundary box, in points.IShape object that represents the new picture.A camera picture is a dynamic linked picture of the referenced range. The sheet of the target range and the sheet to which the shape is added must be the same sheet.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100}
});
IShape shape = worksheet.getShapes().addCameraPicture("=$A$1:$B$2", "CameraPicture1", worksheet.getRange("D1:E2"));
reference - The source range reference for the camera picture, such as an A1-style range reference.name - The name of the picture.range - The target range on the current sheet where the camera picture is placed.IShape object that represents the new picture.