Bruce Thomson

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts

  • Bruce Thomson
    Participant

    Here are routines that access the needed relationships:

           private static void ListRelationships(WorksheetPart wsPart)
            {
                foreach(var partPair in wsPart.Parts)
                {
                    if (!partPair.OpenXmlPart.RelationshipType.EndsWith("/ctrlProp"))
                        continue;
                    Trace.WriteLine("id=" + partPair.RelationshipId + " checked=" + (((FormControlProperties)partPair.OpenXmlPart.RootElement).Checked != null ? "true" : "false"));
                }
            }
    
            private static void ListCheckedItems(WorksheetPart wsPart)
            {
                int n = 0;
                foreach(ControlPropertiesPart cpp in wsPart.ControlPropertiesParts)
                {
                    if(cpp.FormControlProperties.Checked != null)
                        Trace.WriteLine("checkbox " + n.ToString() + " is checked.");
                    n++;
                }
            }
    
            private static void ListItemNames(WorksheetPart wsPart)
            {
                foreach (var altContent in wsPart.DrawingsPart.WorksheetDrawing.OfType<AlternateContent>())
                {
                    AlternateContentChoice child = altContent.OfType<AlternateContentChoice>().First();
                    var loc = child.OfType<TwoCellAnchor>().First();
                    var shape = loc.OfType<Shape>().First();
                    var name = loc.Descendants<NonVisualDrawingProperties>().First().GetAttribute("name", null);
                    Trace.WriteLine("display name=" + shape.InnerText + " internal name=" + name.Value);
                }
            }
    
            private static void ListSheetNames(Worksheet ws)
            {
                Controls controls = ws.Descendants<Controls>().First();
                foreach (var control in controls.Descendants<Control>())
                    Trace.WriteLine("shapeId=" + control.ShapeId.ToString() + " id=" + control.Id + " name=" + control.Name);
            }
    

    Bruce Thomson
    Participant

    I am trying to do this also. If I figure it out, I’ll post it.

    • This reply was modified 5 years, 5 months ago by  Bruce Thomson. Reason: Information in post was wrong
Viewing 2 posts - 1 through 2 (of 2 total)