Hi there, I hope your appreciated help.
First of all I must say that I am a newbie when it comes to net language.
The platform is C#.
This is my problem.
I need replace the value of DateTime.Now.ToString("dd/mm/yyyy") in all slides of my powerpoint presentation generate in OpenXml.
Now if try my net code the new value of DateTime.Now.ToString("dd/mm/yyyy") is superimposed in the old value of DateTime.Now.ToString("dd/mm/yyyy")
If you have link for similar task, please give it me.
Can you help me? thank you in advance.
Your help would be very appreciated
Thanks for your time and hints.
Loading
Nitesh KejriwalPosted Apr 21, 2012, 9:32 PM
Nitesh KejriwalPosted Apr 22, 2012, 7:12 AM
Chevy Mark SunderlandPosted Apr 22, 2012, 4:23 AM
You have right:
string fileName = @"C:\Inetpub\wwwroot\pptx\ppt1.pptx";
using (PresentationDocument prstDoc = PresentationDocument.Open("ppt1.pptx", true))
{
string newValue = DateTime.Now.ToString("MMMM dd, yyyy");
foreach (SlidePart sPart in prstDoc.PresentationPart.SlideParts)
{
Slide sld = sPart.Slide;
var datePlaceholders = sld.CommonSlideData.ShapeTree.ChildElements.OfType
Where(s => s.NonVisualShapeProperties.NonVisualDrawingProperties.Name.Value == "Date Placeholder 3");
if (datePlaceholders != null)
{
datePlaceholders.ToList().ForEach(datePlaceholder=>
{
datePlaceholder.InsertNewValue(newValue);
});
}
}
prstDoc.PresentationPart.Presentation.Save();
}