简体   繁体   中英

Accessing a specific TextBody in PowerPoint OpenXml C#

I am trying to extract text from specific text boxes in a PowerPoint template to fill a web form using OpenXml and C#.

So far, what I have seen online iterates through all text boxes using Slide.Descendants<TextBody>() in a foreach loop, or selects only the first or last text box using Slide.Descendants<TextBody>().First() .

If I know that the text I am looking for is contained in say textBody10, is there a way for me to access that text body directly, or is there a way to identify the name of a given textbody within the foreach loop?

To solve the problem, I used a trial-and-error approach. I indexed the foreach loop with a local variable to identify the TextBody relevant to each field in the form. I am not sure about the robustness of this solution, but it seems to be working fine for now. If anyone has a more elegant solution, I would gladly hear it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM