OK. More info. I looks like I am a little closer. I was not expecting to have to fill in fill color and fill background colour in the shape properties lst as well as creating the fill pattern, but I don't have any issue with doing that. Once I added these I got very close... hard coding stuff to make it work, but here is the code that I believe ought to work...
Chart1ShapeOptions1 := TShapeProperties_Create();
Chart1ShapeOptions1.Anchor := TClientAnchor.Create(true, TFlxAnchorType.MoveAndResize, 583, 0, 597, 0, 1072, 0, 1207, 0);
Chart1ShapeOptions1.ShapeType := TShapeType.Rectangle;
Chart1ShapeOptions1.ObjectType := TObjectType.MicrosoftOfficeDrawing;
Chart1ShapeOptions1.ShapeName := 'Rectangle 1';
Chart1ShapeOptions1.RotateTextWithShape := true;
Chart1ShapeOptions1.ShapeThemeFont := TShapeFont_Create(TFontScheme.Minor, TDrawingColor.FromTheme(TThemeColor.Light1));
Chart1ShapeOptions1.Print := true;
Chart1ShapeOptions1.Visible := true;
Chart1ShapeOptions1.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>';
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.lineColor, 255);
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.lineWidth, 12700);
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.shadowColor, 16777215);
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.shadowOpacity, 0);
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.fFilled, true);
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.fillType, ord(TFillType.Pattern));
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.FillColor, 255);
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.FillBackColor, 0);
Chart1ShapeOptions1.ShapeFill:= TShapeFill_Create(true, TPatternFill_Create(TDrawingColor.FromRgb(255,0,0,nil), TDrawingColor.FromRgb(255,255,0,nil), TDrawingPattern.wdUpDiag));
Chart1ShapeOptions1.ShapeOptions.SetValue(TShapeOption.wzName, 'Rectangle 1');
Chart1.AddAutoShape(Chart1ShapeOptions1);
But! It still doesn't work. I think I have traced the culprit since the file that gets created is correct except for the pattern being "pct10" instead of "wdUpDiag". I put a break point in
_UEscherRecords.TEscherOPTRecord.pas in the method
function TEscherOPTRecord.GetPatternBrush(). At the end there is the following
//Sadly the pattern type doesn't seem to be saved in the file. It is given by the bitmap,
//and we could figure out the pattern from the bitmap, but seems too unreliable.
//So instead we use a pattern which mostly uses the main color.
Result := TShapeFill_Create(HasFill(DefaultHasFill), TPatternFill_Create(ColorFg, ColorBk, TDrawingPattern.pct10));
and you can see where pct10 is hardcoded. I stepped in to the call and once the fill gets created, I manually edited the field in the debugger and let the code finish running. My Excel file loaded with a nice rectangle with the correct fill colours and patterns, so YAY!
I don't believe I can change this behaviour without changing the code and recompiling (unless I am missing something about why I am getting a TEscherOPTRecord, an odd name, and maybe another clue???). I may do at some point if needed, but if this is the issue and it gets fixed in the next release or 2, then I will probably leave it.
I can also confirm by putting a break point as I read back the file I just created above with the correct pattern enumerator, that flexcel does correctly pick the pattern value from the file. Hopefully this is useful.