Пример #1
0
        public static void CompareTableFromPresentationsWithCreatingTable()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareTableFromPresentationsWithCreatingTable.old.pptx";

            // Create to stream of presentation
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);

            // Opening source presentation
            ComparisonPresentationBase sourcePresentation = new ComparisonPresentation(sourceStream);

            Console.WriteLine("Presentation with source path: " + sourcePath + " was loaded.");

            // Getting first Table from source presentation
            ComparisonTableBase sourceTable = (sourcePresentation.Slides[0].Shapes[0] as ComparisonTableBase);
            // Creating Table
            ComparisonTableBase targetTable = new ComparisonTable(100, 100, new double[] { 200, 200 }, new double[] { 50, 50 });

            targetTable[0, 0].TextFrame.Paragraphs[0].Text = "This is first cell in created table.";
            targetTable[0, 1].TextFrame.Paragraphs[0].Text = "This is second cell in created table.";
            targetTable[1, 0].TextFrame.Paragraphs[0].Text = "This is third cell in created table.";
            targetTable[1, 1].TextFrame.Paragraphs[0].Text = "This is fourth cell in created table.";
            Console.WriteLine("New Table was created.");

            // Creating settings for comparison of Tables
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Tables
            ISlidesCompareResult compareResult = sourceTable.CompareWith(targetTable, SlidesComparisonSettings);

            Console.WriteLine("Tables was compared.");

            // Saving result of comparison to new presentation
            string resultPath = @"./../../Components/testresult/CompareTableFromPresentationsWithCreatingTable/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
Пример #2
0
        public static void CompareTablesFromDifferentPresentations()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareTablesFromDifferentPresentations.old.pptx";
            string targetPath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareTablesFromDifferentPresentations.new.pptx";

            // Create to streams of presentations
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);
            Stream   targetStream = assembly.GetManifestResourceStream(targetPath);

            // Opening two presentations
            ComparisonPresentationBase sourcePresentation = new ComparisonPresentation(sourceStream);

            Console.WriteLine("Presentation with source path: " + sourcePath + " was loaded.");
            ComparisonPresentationBase targetPresentation = new ComparisonPresentation(targetStream);

            Console.WriteLine("Presentation with source path: " + targetPath + " was loaded.");

            // Getting first Table from source presentation
            ComparisonTableBase sourceTable = (sourcePresentation.Slides[0].Shapes[0] as ComparisonTableBase);
            // Getting first Table from target presentation
            ComparisonTableBase targetTable = (targetPresentation.Slides[0].Shapes[0] as ComparisonTableBase);

            // Creating settings for comparison of Tables
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Tables
            ISlidesCompareResult compareResult = sourceTable.CompareWith(targetTable, SlidesComparisonSettings);

            Console.WriteLine("Tables was compared.");

            // Saving result of comparison to new presentation
            string resultPath = @"./../../Components/testresult/CompareTablesFromDifferentPresentations/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }