Document Solutions for Excel, Java Edition | Document Solutions
Features / Shapes And Pictures / Shape Adjustment
In This Topic
    Shape Adjustment
    In This Topic

    Apart from changing the size of a shape in DsExcel, you can also change the geometry of a shape and modify its appearance. This can be achieved by setting the adjustment values of shapes, such as AutoShapes or Connectors. It allows you to have more control over the shapes in order to create efficient flowcharts, dashboards and reports.

    DsExcel provides the Adjustments method in the IShape interface to get a collection of adjustment values for the specified AutoShape or Connector.

    The valid ranges of adjustent values for different adjustement types are described below: 

    Adjustment type Valid values
    Linear (horizontal or vertical)

    Value 0.0 represents the left or top edge of the shape.

    Value 1.0 represents the right or bottom edge of the shape.

    For shapes such as connectors and callouts, the values 0.0 and 1.0 correspond to the rectangle defined by the starting and ending points of the connector or callout line.

    Values lesser than 0.0 and greater than 1.0 are also valid.

    The valid values for the adjustment correspond to the valid adjustments that can be made to shapes in Excel by extending the adjustment points.

    For example, if you can only pull an adjustment point half way across the shape in Excel, the maximum value for the corresponding adjustment will be 0.5.

    Radial Value 1.0 represents the shape width. Hence, the maximum value for radial adjustment is 0.5, which is half way across the shape.
    Angle Value is expressed in degrees. If you specify the value outside the range of 180 degree, it will be normalized to be within that range.

    In most cases, if a value exceeds the valid range, it is normalized to the closest valid value.

    Using Code

     Refer to the following example code to adjust the dimensions of a shape in Excel:

    Java
    Copy Code
    private static void AdjustmentPointForShape() {
        // Initialize workbook
        Workbook workbook = new Workbook();
        // Fetch default worksheet
        IWorksheet worksheet = workbook.getWorksheets().get(0);
        // Add a right arrow callout
        IShape shape = worksheet.getShapes().addShape(AutoShapeType.RightArrowCallout, 20, 20, 200, 100);
    
        // Set adjustment points for shapes
        IAdjustments adjustments = shape.getAdjustments();
    
        // To count adjustment points
        int c = adjustments.getCount();
        System.out.println("Count of Adjustment Values: " + c);
    
        adjustments.set(0, 0.5);// arrow neck width
        adjustments.set(1, 0.4);// arrow head width
        adjustments.set(2, 0.5);// arrow head height
        adjustments.set(3, 0.6);// text box width
    
        // Saving workbook to Xlsx
        workbook.save("17-AdjustmentPointForShape.xlsx", SaveFileFormat.Xlsx);