EPPlus
EPPlus copied to clipboard
ParentGroup of ExcelDrawing
Hi, I have several problems with an excel that has some grouped drawings.
I want to access to the drawing inside the group (for example: D2_a_BT, D2_b_BT, etc)
I think to access this drawing I would have to do like this (to edit the text of the shape):
sheet1.Drawings.Item("Img_D2_BT").ParentGroup.Drawings.Item("D2_a_BT").As.Shape.Text = "A1"
The problem is that ParentGroup
is null.
I also try to UnGroup
the shape to edit the child and after Group
again, but also I can UnGropup
the shape.
It seems that epplus takes it as not being grouped.
Also in the imagen you can see that the property Size
is null too.
I attached my Excel CalcTF_Amb4.xlsx
It seems like there is a bug when trying to access child drawing via the name. I will add a fix for that. For now, use a linq query or similar...
var groupDrawing = ((ExcelGroupShape)sheet.Drawings["img_d2_bt"]);
var childLine1 = groupDrawing.Drawings.FirstOrDefault(x=> x.Name=="D2_Line1_BT");
//Instead of...
var childLine2 = groupDrawing.Drawings["D2_Line2_BT"];
//...Or use the index:
var childc = groupDrawing.Drawings[3];
The Size
property will be null on drawings that have the EditAs
property set to OfficeOpenXml.Drawing.eEditAs.TwoCell
Depending on the EditAs
property value, you use the properties From
, To
, Position
or Size
to get/set the drawings position.
The ParentGroup will be set to null for all top-level drawing (in the worksheet.Drawings Collection). Group Drawings (like "D2_Line1_BT"), have the ParentGroup
property set to the group drawing that contains it (in this case "img_d2_bt").
Thank you, I use linq and it works. And also works the Size
, I already have the property EditAs
set to OneCell
but after I call the Size
(so I move before and it works).
Great, I have added a fix for the Name Indexer issue.
Fixed in EPPlus 7.1.3