Bruce Thomson
Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
December 11, 2018 at 1:44 am in reply to: How to access a FormControl checkbox in an Excel sheet using OpenXML SDK #7751
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); }
December 10, 2018 at 5:06 am in reply to: How to access a FormControl checkbox in an Excel sheet using OpenXML SDK #7749I am trying to do this also. If I figure it out, I’ll post it.
- This reply was modified 5 years, 11 months ago by Bruce Thomson. Reason: Information in post was wrong
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)