public static bool ReadFileCompateText(string path, string s) { Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation(path, FileFormat.Auto); Regex r = new Regex(s, RegexOptions.IgnoreCase); StringBuilder sb = new StringBuilder(); for (int i = 0; i < presentation.Slides.Count; i++) { for (int j = 0; j < presentation.Slides[i].Shapes.Count; j++) { if (presentation.Slides[i].Shapes[j] is IAutoShape) { IAutoShape shape = presentation.Slides[i].Shapes[j] as IAutoShape; if (shape.TextFrame != null) { foreach (TextParagraph tp in shape.TextFrame.Paragraphs) { Match m = r.Match(tp.Text); if (m.Success) { presentation.Dispose(); return(true); } } } } } } presentation.Dispose(); return(false); }
public static void SavePPtxAsHtml(string sourceFile, string targetFile) { using (Spire.Presentation.Presentation ppt = new Spire.Presentation.Presentation()) { ppt.LoadFromFile(sourceFile); ppt.SaveToFile(targetFile, FileFormat.Html); } string newHtml = File.ReadAllText(targetFile); string toMatch = "Evaluation Warning : The document was created with Spire.Presentation for .NET"; newHtml = newHtml.Replace(toMatch, ""); File.WriteAllText(targetFile, newHtml); }
static void Main(string[] args) { while (true) { var userProfile = Environment.GetEnvironmentVariable("USERPROFILE"); Console.WriteLine("{0} Start update", DateTime.Now.ToString("s")); var presentation = new Spire.Presentation.Presentation(); presentation.LoadFromFile(userProfile + @"\OneDrive\Famille\Menu de la semaine.pptx"); var shape = (IAutoShape)presentation.Slides[3].Shapes[1]; GetEvents(shape.TextFrame); var shape2 = (IAutoShape)presentation.Slides[3].Shapes[2]; shape2.TextFrame.Paragraphs.Clear(); shape2.TextFrame.Paragraphs.Append(new TextParagraph() { Text = "Dernière mise à jour: " + DateTime.Now.ToString("dddd le d MMMM yyyy @ H:mm").Translate() }); presentation.SaveToFile(userProfile + @"\OneDrive\Famille\Menu de la semaine.pptx", FileFormat.Pptx2010); Console.WriteLine("{0} End update", DateTime.Now.ToString("s")); Console.WriteLine("{0} Waiting for next execution", DateTime.Now.ToString("s")); Thread.Sleep(60000); while (true) { Console.Write("."); var minute = DateTime.Now.Minute; if (minute % 15 == 0) { Console.WriteLine(); break; } Thread.Sleep(1000); } } }