[]
        
(Showing Draft Content)

IShapes

Interface IShapes

All Superinterfaces:
Iterable<IShape>

public interface IShapes extends Iterable<IShape>
Represents a collection of all 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);
 
  • Method Details

    • getRange

      IShapeRange getRange(String[] index)
      Returns a shape range ( IShapeRange) 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"});
       
      Parameters:
      index - The names of the shapes to include in the returned shape range.
      Returns:
      An IShapeRange object that represents the specified subset of shapes.
    • getRange

      IShapeRange getRange(int[] index)
      Returns a shape range ( 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});
       
      Parameters:
      index - The index numbers of the shapes to include in the returned shape range.
      Returns:
      A IShapeRange object that contains the specified shapes.
    • get

      IShape get(int index)
      Returns a single object from a collection.

      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");
       
      Parameters:
      index - The zero-based index number for the object.
      Returns:
      The IShape at the specified index.
    • get

      IShape get(String name)
      Returns a single object from a collection.

      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");
       
      Parameters:
      name - The String name of the object to retrieve.
      Returns:
      The IShape object with the specified name.
    • getCount

      int getCount()
      Returns the number of objects in the collection.

      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();
       
      Returns:
      The number of objects in the collection.
    • addChart

      IShape addChart(ChartType chartType, double left, double top, double width, double height)
      Creates a chart at the specified location on the active sheet.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object.
    • addChart

      IShape addChart(ChartType chartType, IRange range)
      Creates a chart at the specified range on the current sheet.

      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);
       
      Parameters:
      chartType - The chart type.
      range - The target range on the current sheet where the chart is created.
      Returns:
      The IShape object that represents the new chart.
    • addChart

      IShape addChart(String name, ChartType chartType, double left, double top, double width, double height)
      Creates a chart at the specified location on the active sheet.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new chart.
    • addChart

      IShape addChart(String name, ChartType chartType, IRange range)
      Creates a chart at the specified range on the current sheet.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new chart.
    • addPicture

      IShape addPicture(String filename, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing file and returns the 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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if the specified file cannot be read.
    • addPicture

      IShape addPicture(String filename, IRange range) throws IOException
      Creates a picture from an existing file at the specified range on the current sheet.

      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");
       
      Parameters:
      filename - The file from which the picture is created.
      range - The target range on the current sheet.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if the specified file cannot be read.
    • addPicture

      IShape addPicture(String name, String filename, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing file and adds it to the worksheet at the specified position and size.

      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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if the picture file cannot be read.
    • addPicture

      IShape addPicture(String name, String filename, IRange range) throws IOException
      Creates a picture from an existing file at the specified range on the current sheet.

      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");
       
      Parameters:
      name - The picture name.
      filename - The file from which the picture is created.
      range - The target range on the current sheet.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if the picture file cannot be read.
    • addPicture

      IShape addPicture(InputStream stream, ImageType type, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing stream.

      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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if an I/O error occurs while reading the stream.
    • addPicture

      IShape addPicture(InputStream stream, ImageType type, IRange range) throws IOException
      Creates a picture from an existing stream at the specified range on the current sheet.

      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");
       }
       
      Parameters:
      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.
      Returns:
      The IShape object.
      Throws:
      IOException - if an I/O error occurs while reading the stream.
    • addPicture

      IShape addPicture(String name, InputStream stream, ImageType type, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing 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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if an I/O error occurs while reading the stream.
    • addPicture

      IShape addPicture(String name, InputStream stream, ImageType type, IRange range) throws IOException
      Creates a picture from an existing stream at the specified range on the current sheet.

      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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if an I/O error occurs while reading the stream.
    • addShape

      IShape addShape(AutoShapeType type, double left, double top, double width, double height)
      Adds a new preset shape to the worksheet and returns the created 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");
       
      Parameters:
      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.
      Returns:
      The created IShape object.
    • addShape

      IShape addShape(AutoShapeType type, IRange range)
      Returns the 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");
       
      Parameters:
      type - Specifies the type of preset shape to create.
      range - The target range on the current sheet.
      Returns:
      The IShape object that represents the new preset shape.
    • addShape

      IShape addShape(String name, AutoShapeType type, double left, double top, double width, double height)
      Returns the 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());
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new preset shape.
    • addShape

      IShape addShape(String name, AutoShapeType type, IRange range)
      Returns the 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");
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new preset shape.
    • addConnector

      IShape addConnector(ConnectorType type, double beginX, double beginY, double endX, double endY)
      Creates a connector and returns the 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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new connector.
    • addConnector

      IShape addConnector(ConnectorType type, IRange range)
      Creates a connector 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("B12:D12");
       IShape connector = worksheet.getShapes().addConnector(ConnectorType.Curve, range);
       connector.setName("FlowConnector");
       
      Parameters:
      type - The connector type to add.
      range - The target range on the current sheet that defines the connector position and size.
      Returns:
      The IShape object that represents the new connector.
    • addConnector

      IShape addConnector(String name, ConnectorType type, double beginX, double beginY, double endX, double endY)
      Creates a connector and returns the 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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new connector.
    • addConnector

      IShape addConnector(String name, ConnectorType type, IRange range)
      Creates a connector at the specified range on the current sheet.

      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);
       
      Parameters:
      name - The name of the connector.
      type - The connector type to add.
      range - The target range on the current sheet.
      Returns:
      The IShape object that represents the new connector.
    • addChartInPixel

      IShape addChartInPixel(ChartType chartType, double left, double top, double width, double height)
      Creates a chart at the specified location on the active sheet.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object.
    • addChartInPixel

      IShape addChartInPixel(String name, ChartType chartType, double left, double top, double width, double height)
      Creates a chart with the specified name at the specified location on the active sheet.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new chart.
    • addPictureInPixel

      IShape addPictureInPixel(String filename, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing file and returns the 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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if the specified file cannot be read.
    • addPictureInPixel

      IShape addPictureInPixel(String name, String filename, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing file. Returns the 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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object.
      Throws:
      IOException - if the picture file cannot be read.
    • addPictureInPixel

      IShape addPictureInPixel(InputStream stream, ImageType type, double left, double top, double width, double height) throws IOException
      Creates a picture from an existing stream. Returns the 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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if an I/O error occurs while reading the picture stream.
    • addPictureInPixel

      IShape addPictureInPixel(String name, InputStream stream, ImageType type, double left, double top, double width, double height) throws IOException
      Creates a picture with the specified name from an existing stream. Returns the 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);
       }
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      IOException - if an I/O error occurs while reading the image stream.
    • addShapeInPixel

      IShape addShapeInPixel(AutoShapeType type, double left, double top, double width, double height)
      Creates a new preset shape in the worksheet using pixel-based position and size.

      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");
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new preset shape.
    • addShapeInPixel

      IShape addShapeInPixel(String name, AutoShapeType type, double left, double top, double width, double height)
      Creates a preset shape with the specified name at the specified location on the worksheet.

      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");
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new preset shape.
    • addConnectorInPixel

      IShape addConnectorInPixel(ConnectorType type, float beginX, float beginY, float endX, float endY)
      Creates a connector and returns the 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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new connector.
    • addConnectorInPixel

      IShape addConnectorInPixel(String name, ConnectorType type, float beginX, float beginY, float endX, float endY)
      Creates a connector and returns the 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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new connector.
    • addCameraPicture

      IShape addCameraPicture(String reference, double left, double top)
      Creates a camera picture from a reference range and places it at the specified position.

      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");
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
    • addCameraPicture

      IShape addCameraPicture(String reference, double left, double top, double width, double height)
      Creates a camera picture from a reference range.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
    • addCameraPicture

      IShape addCameraPicture(String reference, IRange range)
      Creates a camera picture from a reference range and places it in the specified target range on the current sheet.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
      Throws:
      UnsupportedOperationException - if range is on a different worksheet.
    • addCameraPicture

      IShape addCameraPicture(String reference, String name, double left, double top)
      Creates a camera picture from a reference range and places it at the specified position.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
    • addCameraPicture

      IShape addCameraPicture(String reference, String name, double left, double top, double width, double height)
      Creates a camera picture from a reference range and places it at the specified position and size.

      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);
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.
    • addCameraPicture

      IShape addCameraPicture(String reference, String name, IRange range)
      Creates a camera picture from a referenced source range and places it in the specified target range on the current sheet.

      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"));
       
      Parameters:
      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.
      Returns:
      The IShape object that represents the new picture.