Adding a AutoShapeType.ROUNDED_RECTANGLE will return a CellsDrawing
- the question is how do I specify the value for the round/radius of that new shape?
@duranperez Hi,
Excel changes the adjustment value of the shape by dragging a series of adjustment points, and there is no special setting interface. Since the number and meaning of adjustment points are different for different shapes, we can only add and read adjustment values. Our current api design does not implement such a function, and the adjustment value cannot be changed by setting the round/radius.
I have logged a ticket with an id “ CELLSNET-52563” for your issue.
We will let you know as soon as we make progress.
I want to accomplish round corners like this picture:
Screen Shot 2023-01-11 at 11.43.35 PM.png (30.2 KB)
Is there any other I can do that? Such as an array of adjustment points?
Sure!
For example, this file has 5 boxes.
round.xlsx.zip (7.8 KB)
When you create an AutoShape with ROUNDED_RECTANGLE type, Aspose creates a #5 rectangle by default, but we need to manipulate the shape to get a #1 round (examples in the attached file).
Thanks.
Thanks for the sample file. We have logged it with your existing ticket “CELLSNET-52563” into our database. We will evaluate it soon.
@duranperez Hi,
According to your description, the following code may help you:
Workbook workbook = new Workbook();
int row = 8;
int shapeWidth = 325;
int shapeHeight = 125;
int[] radiusVaules = new int[] { 5, 17, 29, 47, 62 };//your desired radius
for (int i = 0; i < radiusVaules.Length; i++)
{
Shape shape = workbook.Worksheets[0].Shapes.AddAutoShape(AutoShapeType.RoundedRectangle, 1+row*i, 0, 1, 0, shapeHeight, shapeWidth);
float val = (float)radiusVaules[i] / Math.Min(shapeWidth, shapeHeight);//get the value of the adjustment point
shape.Geometry.ShapeAdjustValues.Add("adj", val);
}
workbook.Save("CELLSNET-52563.xlsx");
Sorry, that does not work for Aspose Cells for Java.
The .add
method in ShapeGuideCollection
is not very helpful, and I cannot add a ShapeGuide
since the constructor is not public.
How can I achieve this with Aspose Cells for Java v21.12?
Thanks.
@duranperez Hi,
Here is the java version of the code
Workbook workbook = new Workbook();
int row = 8;
int shapeWidth = 325;
int shapeHeight = 125;
int[] radiusVaules = new int[] { 5, 17, 29, 47, 62 };//your desired radius
for (int i = 0; i < radiusVaules.length; i++)
{
Shape shape = workbook.getWorksheets().get(0).getShapes().addAutoShape(AutoShapeType.ROUNDED_RECTANGLE, 1+row*i, 0, 1, 0, shapeHeight, shapeWidth);
shape.getGeometry().getShapeAdjustValues().clear();//Clean up any old adjustment values that may exist
float val = (float)radiusVaules[i] / Math.min(shapeWidth, shapeHeight);//get the value of the adjustment point
shape.getGeometry().getShapeAdjustValues().add("adj", val);
}
workbook.save("CELLSNET-52563-java.xlsx");
Notice:
You don’t need to add the ‘ShapeGuide’ object yourself, the ‘add’ function will do it for you.
You can also use the following code to obtain the adjustment value list of shape for operation.
ShapeGuideCollection shapeGuideList= shape.getGeometry().getShapeAdjustValues();
shapeGuideList.clear();
shapeGuideList.add("adj", 0.1f);
Please refer to the resulting file I got with the sample code:
resFile.zip (7.1 KB)
Thank you for your responses, but no, it does not work.
The Aspose Cells for Java v21.12 ShapeGuideCollection.add
method signature is 1 Object type!
mehod-signature.png (20.3 KB)
And when I try to pass 2 arguments, it gives me a compiler error:
compiler-error.png (25.8 KB)