We create excel files in which cell values are represented by shapes. The shapes are positioned in the cell.
The code seems to be taken from APIMate:
ShapeOptions1 := TShapeProperties_Create;
ShapeOptions1.Anchor := TClientAnchor.Create(TFlxAnchorType.MoveAndResize, lZeile, lBalken, i + S.KW1, 0, lZeile, 251, i + S.KW1 +1, 0);
ShapeOptions1.ShapeType := TShapeType.Rectangle;
ShapeOptions1.ObjectType := TObjectType.MicrosoftOfficeDrawing;
ShapeOptions1.ShapeName := 'Abverkauf';
ShapeOptions1.RotateTextWithShape := true;
ShapeOptions1.ShapeThemeFont := TShapeFont_Create(TFontScheme.Minor, TDrawingColor.FromTheme(TThemeColor.Background1));
ShapeOptions1.Print := true;
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.ShapeOptions.SetValue(TShapeOption.fillColor, 255);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.fillOpacity, 0.5);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.fillBackColor, 134217808);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.fFilled, true);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.lineColor, 5296274);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.lineWidth, 12700);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.shadowColor, 0);
ShapeOptions1.ShapeOptions.SetValue(TShapeOption.wzName, 'Abverkauf');
XLSX.AddAutoShape(ShapeOptions1);
Outline levels are added:
XLSX.SetRowOutlineLevel(lErsteTeile - 1, lLetzteZeile + 1, 1);
When we collapse the document by
XLSX.CollapseOutlineRows(1, TCollapseChildrenMode.Collapsed);
the shapes in the collapsed rows are not visible anymore when the rows ar uncollapsed.
When we collapse the document by Excel OLE
Excel := CreateOleObject('Excel.Application');
Excel.Workbooks.Open(lDatei);
Excel.ActiveSheet.OutLine.ShowLevels(1,EmptyParam);
Excel.DisplayAlerts := False;
Excel.Workbooks[1].SaveAs(lDatei,Excel.Workbooks[1].fileformat);
Excel.Quit;
Excel.Free;
the shapes stay in the cells.
I took a look in the created Excel files and found a difference:
On the left side is the drawing1.xml from the file collapsed by flexcel.
It looks like anchor values get lost.