Flexcel 7.9 AddAutoShape to chart not working in APIMate

In the documentation it says that for Chart.AddAutoShape I should create a simple file in Excel and use APIMate. I tried this with a simple embedded chart, and a single rectangle placed on the chart. API mate produces code a perfect chart, but no mention of the shape.

Since the document defers to APIMate and APImate does not do it there is no good example.

I have tried this without help, and unfortunately I get an Exception when I try to add the Autoshape...

I use code like this

ShapeOptions1 := TShapeProperties_Create;
ShapeOptions1.Anchor := TClientAnchor.Create(true, TFlxAnchorType.MoveAndResize, 1693, 0, 1251, 0, 1889, 0, 1942, 0);
ShapeOptions1.ShapeType := TShapeType.Rectangle;
ShapeOptions1.ObjectType := TObjectType.MicrosoftOfficeDrawing;
ShapeOptions1.ShapeName := 'TextBox 1';
ShapeOptions1.Text := 'NIMHR346 Sample D6';
ShapeOptions1.TextFlags := 530;
ShapeOptions1.RotateTextWithShape := true;
ShapeOptions1.ShapeThemeFont := TShapeFont_Create(TFontScheme.Minor, TDrawingColor.FromSystem(TSystemColor.WindowText));
ShapeOptions1.Print := true;
ShapeOptions1.Visible := true;
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.wzName, 'TextBox 1');

Chart1.AddAutoShape(ShapeOptions1);

In case it is useful I have traced the exception through into the Flexcel code. I know the line it is occuring (see below), but not sure what is causing the relevant object to be returning nil

In _UXlsSheet.TFlxChart
Procedure TFlxChart.AddAutoShape()....

The line

op.Patriarch := TEscherDwgCache(TFlxChart(space.FlxChart).Drawing.DwgCache).Patriarch;

causes EAccessViolation because

space.FlxChart returns nil

This behaviour seems to only occur when I am creating an embedded chart using the API first. If I try this on a chart sheet when loading an existing file it works fine with no exception

I am going to have to try creating a different template with an embedded chart, and slightly modify my code that adds to the template graph... I will report back later.

Indeed, when adding a chart with the API, a value wouldn't be set which would later cause AddAutoshape to crash. This was fixed and the fix will be available in 7.10

Good news, thank you. Really looking forward to the new release.

@adrian . Just working on a presentation for the UK developers group next week about Flexcel and some of the more advanced features. This is one of the things I issue above is one I have been wanting to do for a while. I started working on the examples in 7.09 but have just had a chance to update to 7.10.

I can confirm that APImate does now produce code for my text annotations on graphs, and it does handle font changes (color, superscript, etc). Exceuting the code from APImate gives me very close to perfect results. I am really happy to see this :grinning: :grinning: and will be showing it in the presentation.

It looks like there are a few minor differences (around margins of the text box), but nothing that will stop me for now.

Thank you