Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
I am creating one slide PowerPoint file using open XML. I have tagged the placeholder in the PPT which i need to update programatically. I am able to find the placeholder and can update its value from the database.

Now the problem is I need to display some HTML code which user has input using WYSIWYG editor in a same format as user has entered e.g. like in bullets.

When i try to replace the place holder with the HTML text, the HTML text was pasted as is like all the tags etc.

    var presPart = myPres.PresentationPart;
        var slideIdList = presPart.Presentation.SlideIdList;

        var list = slideIdList.ChildElements
                    .Cast<SlideId>()
                    .Select(x => presPart.GetPartById(x.RelationshipId))
                    .Cast<SlidePart>();


        var tableSlidePart = (SlidePart)list.First();
        var secondSlidePart = (SlidePart)list.Last();
        var current = tableSlidePart;
Below line is working fine when i need to paste simple plane text
        List<DocumentFormat.OpenXml.Drawing.Text> textList = tableSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.Text>().Where(t => t.Text.Equals("IntroText")).ToList();
        foreach (DocumentFormat.OpenXml.Drawing.Text text in textList)
        {
            text.Text = "Some Text";
        }
But when i wanted to paste HTML into the placeholder it is treated as normal plain string.
     textList = null;
        textList = tableSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.Text>().Where(t => t.Text.Equals("##DESCRIPTION##")).ToList();
        foreach (DocumentFormat.OpenXml.Drawing.Text text in textList)
            text.Text = "<html><table><tr><td><b>Hello</b></td></tr></table></html>";

Any help or pointer would be appreciated. Thank you in advance


What I have tried:

Code attached above in my questions. What exactly I am trying to do.
Posted
Comments
ravinimje 8-Nov-17 5:38am    
I am also facing the same problem.if you got the solution then please let me know.
i have tried open xml productivity tool for formatting but not getting the proper answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900