Sorry about that. I just checked it and indeed APIMate is ignoring grouped objects, and we really don't support adding them via the API. All the support to do it is there (we need to render those objects and add them when reading xlsx files), but the AddAutoShape method doesn't have an overload to do it.
We will be adding the ability to add grouped shapes with the API for the next release.
About the second issue, I am not 100% sure I understood what you want (you mention that you want to prevent overflow, but also that the problem is that the lines are broken in many lines). Those are separate properties: One is to keep the text without wrapping (word wrap in the shape properties):
The other is to keep the text from overflowing or not the shape when it reaches the right side. If the text overflows, it will write the text outside the shape:
And just as a side note, this second property will be ignored if you save as xls:
As said, I didn't know which one was exactly, so I made 2 boxes and opened them with APIMate (without grouping them, because as per 1. if we group them APIMate will currently ignore them)
This is the code I got, but you can really set the properties as you like and APIMate should tell you the code:
program Project2;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,FlexCel.VCLSupport, FlexCel.Core, FlexCel.XlsAdapter;
procedure CreateExcelFile(const xls: TExcelFile);
var
Paragraphs: TArray<TDrawingTextParagraph>;
ParagraphRuns: TArray<TDrawingTextRun>;
TextAttributes: TDrawingTextAttributes;
RunProperties: TDrawingTextProperties;
ParagraphProperties: TDrawingParagraphProperties;
ParagraphEndProperties: TDrawingTextProperties;
ShapeOptions1: IShapeProperties;
ShapeOptions2: IShapeProperties;
begin
xls.NewFile(1, TExcelFileFormat.v2023); //Create a new Excel file with 1 sheet.
//Set the names of the sheets
xls.ActiveSheet := 1;
xls.SheetName := 'Sheet1';
//Objects
Paragraphs := nil; //SetLength will resize the array in place. We set it to nil first to create a new array.
SetLength(Paragraphs, 1);
ParagraphRuns := nil; //SetLength will resize the array in place. We set it to nil first to create a new array.
SetLength(ParagraphRuns, 2);
TextAttributes := TDrawingTextAttributes.Create(nil, 'en-US', '', 1100, nil, nil, NullableTDrawingUnderlineStyle.Null, NullableTDrawingTextStrike.Null, nil, NullableTDrawingTextCapitalization.Null, NullableTDrawingCoordinate.Null, nil, nil, nil, false, false, false, 0, '');
RunProperties := TDrawingTextProperties.Create(nil, TextAttributes);
ParagraphRuns[0] := TDrawingTextRun.Create('this is', RunProperties);
TextAttributes := TDrawingTextAttributes.Create(nil, 'en-US', '', 1100, nil, nil, NullableTDrawingUnderlineStyle.Null, NullableTDrawingTextStrike.Null, nil, NullableTDrawingTextCapitalization.Null, NullableTDrawingCoordinate.Null, nil, 0, nil, false, false, false, 0, '');
RunProperties := TDrawingTextProperties.Create(nil, TextAttributes);
ParagraphRuns[1] := TDrawingTextRun.Create(' a text that doesn''t wrap', RunProperties);
ParagraphProperties := TDrawingParagraphProperties.Create(347663, 0, 0, TDrawingCoordinate.Create(-342900), TDrawingAlignment.Left, TDrawingCoordinate.Create(0), nil, true, TDrawingFontAlign.BaseLine, true, false, TDrawingTextProperties.Empty, false);
TextAttributes := TDrawingTextAttributes.Create(nil, 'en-US', '', 1100, nil, nil, NullableTDrawingUnderlineStyle.Null, NullableTDrawingTextStrike.Null, nil, NullableTDrawingTextCapitalization.Null, NullableTDrawingCoordinate.Null, nil, nil, nil, false, false, false, 0, '');
ParagraphEndProperties := TDrawingTextProperties.Create(nil, TextAttributes);
Paragraphs[0] := TDrawingTextParagraph.Create(ParagraphRuns, ParagraphProperties, ParagraphEndProperties);
ShapeOptions1 := TShapeProperties_Create();
ShapeOptions1.Anchor := TClientAnchor.Create(TFlxAnchorType.MoveAndResize, 2, 201, 3, 480, 6, 148, 5, 560);
ShapeOptions1.ShapeType := TShapeType.Rectangle;
ShapeOptions1.ObjectType := TObjectType.MicrosoftOfficeDrawing;
ShapeOptions1.ShapeName := 'Rectangle 1';
ShapeOptions1.Text := TDrawingRichString.Create(Paragraphs);
ShapeOptions1.LockText := true;
ShapeOptions1.TextHorizontalAlignment := THFlxAlignment.left;
ShapeOptions1.TextVerticalAlignment := TVFlxAlignment.top;
ShapeOptions1.RotateTextWithShape := true;
ShapeOptions1.ShapeThemeFont := TShapeFont_Create(TFontScheme.Minor, TDrawingColor.FromTheme(TThemeColor.Light1));
ShapeOptions1.Visible := true;
ShapeOptions1.ShapeGeometry := '<?xml version="1.0" encoding="utf-8" standalone="yes"?><a:shapeGeom xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:prstGeom'
+ ' prst="rect"><a:avLst /></a:prstGeom></a:shapeGeom>';
ShapeOptions1.ShapeLine := TShapeLine_Create(true, nil, TDrawingColor.FromTheme(TThemeColor.Accent1, TColorTransformArray.Create(TColorTransform.Create(TColorTransformType.Shade, 0.15))), TFormattingType.Moderate);
ShapeOptions1.ShapeFill := TShapeFill_Create(nil, true, TFormattingType.Subtle, TDrawingColor.FromTheme(TThemeColor.Accent1), false);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.WrapText, 2);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.shadowColor, 16777215);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.shadowOpacity, 0);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.wzName, 'Rectangle 1');
xls.AddAutoShape(ShapeOptions1);
Paragraphs := nil; //SetLength will resize the array in place. We set it to nil first to create a new array.
SetLength(Paragraphs, 1);
ParagraphRuns := nil; //SetLength will resize the array in place. We set it to nil first to create a new array.
SetLength(ParagraphRuns, 2);
TextAttributes := TDrawingTextAttributes.Create(nil, 'en-US', '', 1100, nil, nil, NullableTDrawingUnderlineStyle.Null, NullableTDrawingTextStrike.Null, nil, NullableTDrawingTextCapitalization.Null, NullableTDrawingCoordinate.Null, nil, nil, nil, false, false, false, 0, '');
RunProperties := TDrawingTextProperties.Create(nil, TextAttributes);
ParagraphRuns[0] := TDrawingTextRun.Create('this is a text', RunProperties);
TextAttributes := TDrawingTextAttributes.Create(nil, 'en-US', '', 1100, nil, nil, NullableTDrawingUnderlineStyle.Null, NullableTDrawingTextStrike.Null, nil, NullableTDrawingTextCapitalization.Null, NullableTDrawingCoordinate.Null, nil, 0, nil, false, false, false, 0, '');
RunProperties := TDrawingTextProperties.Create(nil, TextAttributes);
ParagraphRuns[1] := TDrawingTextRun.Create(' that wraps the line', RunProperties);
ParagraphProperties := TDrawingParagraphProperties.Create(347663, 0, 0, TDrawingCoordinate.Create(-342900), TDrawingAlignment.Left, TDrawingCoordinate.Create(0), nil, true, TDrawingFontAlign.BaseLine, true, false, TDrawingTextProperties.Empty, false);
TextAttributes := TDrawingTextAttributes.Create(nil, 'en-US', '', 1100, nil, nil, NullableTDrawingUnderlineStyle.Null, NullableTDrawingTextStrike.Null, nil, NullableTDrawingTextCapitalization.Null, NullableTDrawingCoordinate.Null, nil, nil, nil, false, false, false, 0, '');
ParagraphEndProperties := TDrawingTextProperties.Create(nil, TextAttributes);
Paragraphs[0] := TDrawingTextParagraph.Create(ParagraphRuns, ParagraphProperties, ParagraphEndProperties);
ShapeOptions2 := TShapeProperties_Create();
ShapeOptions2.Anchor := TClientAnchor.Create(TFlxAnchorType.MoveAndResize, 2, 107, 6, 288, 6, 67, 8, 368);
ShapeOptions2.ShapeType := TShapeType.Rectangle;
ShapeOptions2.ObjectType := TObjectType.MicrosoftOfficeDrawing;
ShapeOptions2.ShapeName := 'Rectangle 2';
ShapeOptions2.Text := TDrawingRichString.Create(Paragraphs);
ShapeOptions2.LockText := true;
ShapeOptions2.TextHorizontalAlignment := THFlxAlignment.left;
ShapeOptions2.TextVerticalAlignment := TVFlxAlignment.top;
ShapeOptions2.RotateTextWithShape := true;
ShapeOptions2.TextHorizontalOverflow := TTextHorzOverflow.Clip;
ShapeOptions2.TextVerticalOverflow := TTextVertOverflow.Clip;
ShapeOptions2.ShapeThemeFont := TShapeFont_Create(TFontScheme.Minor, TDrawingColor.FromTheme(TThemeColor.Light1));
ShapeOptions2.Visible := true;
ShapeOptions2.ShapeGeometry := '<?xml version="1.0" encoding="utf-8" standalone="yes"?><a:shapeGeom xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:prstGeom'
+ ' prst="rect"><a:avLst /></a:prstGeom></a:shapeGeom>';
ShapeOptions2.ShapeLine := TShapeLine_Create(true, nil, TDrawingColor.FromTheme(TThemeColor.Accent1, TColorTransformArray.Create(TColorTransform.Create(TColorTransformType.Shade, 0.15))), TFormattingType.Moderate);
ShapeOptions2.ShapeFill := TShapeFill_Create(nil, true, TFormattingType.Subtle, TDrawingColor.FromTheme(TThemeColor.Accent1), false);
ShapeOptions2.ShapeOptions.SetValue(TShapeOption.shadowColor, 16777215);
ShapeOptions2.ShapeOptions.SetValue(TShapeOption.shadowOpacity, 0);
ShapeOptions2.ShapeOptions.SetValue(TShapeOption.wzName, 'Rectangle 2');
xls.AddAutoShape(ShapeOptions2);
end;
var
xls: TXlsFile;
begin
xls := TXlsFile.Create(true);
try
CreateExcelFile(xls);
//Save the file as XLS
xls.Save('..\..\shapes.xlsx');
finally
xls.Free;
end
end.