Example #1
0
        public static void CompareTwoCreatingTables()
        {
            // Creating Tables
            ComparisonTableBase     sourceTable       = new ComparisonTable(100, 100, new double[] { 200, 200 }, new double[] { 50, 50 });
            ComparisonParagraphBase sourceParagraph00 = new ComparisonParagraph();

            sourceParagraph00.Text = "This is first cell in source table.";
            sourceTable[0, 0].TextFrame.Paragraphs.Add(sourceParagraph00);
            ComparisonParagraphBase sourceParagraph01 = new ComparisonParagraph();

            sourceParagraph01.Text = "This is second cell in source table.";
            sourceTable[0, 1].TextFrame.Paragraphs.Add(sourceParagraph01);
            ComparisonParagraphBase sourceParagraph10 = new ComparisonParagraph();

            sourceParagraph10.Text = "This is third cell in source table.";
            sourceTable[1, 0].TextFrame.Paragraphs.Add(sourceParagraph10);
            ComparisonParagraphBase sourceParagraph11 = new ComparisonParagraph();

            sourceParagraph11.Text = "This is fourth cell in source table.";
            sourceTable[1, 1].TextFrame.Paragraphs.Add(sourceParagraph11);
            Console.WriteLine("New Table was created.");

            ComparisonTableBase     targetTable       = new ComparisonTable(100, 100, new double[] { 200, 200 }, new double[] { 50, 50 });
            ComparisonParagraphBase targetParagraph00 = new ComparisonParagraph();

            targetParagraph00.Text = "This is first cell in target table.";
            targetTable[0, 0].TextFrame.Paragraphs.Add(targetParagraph00);
            ComparisonParagraphBase targetParagraph01 = new ComparisonParagraph();

            targetParagraph01.Text = "This is second cell in target table.";
            targetTable[0, 1].TextFrame.Paragraphs.Add(targetParagraph01);
            ComparisonParagraphBase targetParagraph10 = new ComparisonParagraph();

            targetParagraph10.Text = "This is third cell in target table.";
            targetTable[1, 0].TextFrame.Paragraphs.Add(targetParagraph10);
            ComparisonParagraphBase targetParagraph11 = new ComparisonParagraph();

            targetParagraph11.Text = "This is fourth cell in target table.";
            targetTable[1, 1].TextFrame.Paragraphs.Add(targetParagraph11);
            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/CompareTwoCreatingTables/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("");
        }
Example #2
0
        public static void CompareTableFromDocumentWithCreatingTable()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Words.Components.data.CompareTableFromDocumentWithCreatingTable.source.docx";

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

            // Opening source document
            IComparisonDocument sourceDocument = new ComparisonDocument(sourceStream);

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

            // Getting first Table from source document
            IComparisonTable sourceTable = sourceDocument.Sections[0].Body.GetChildNodes(ComparisonNodeType.Table, false)[0] as IComparisonTable;

            // Creating Table
            IComparisonTable     targetTable = new ComparisonTable(new double[] { 100, 100, 100 }, new double[] { 20, 20 });
            IComparisonParagraph paragraph   = targetTable.Rows[0].Cells[0].AddParagraph();

            paragraph.AddRun("This is cell.");
            paragraph = targetTable.Rows[0].Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell of target table.");
            paragraph = targetTable.Rows[1].Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell.");
            Console.WriteLine("New Table was created.");

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

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

            // Saving result of comparison to new document
            string resultPath          = @"./../../Components/testresult/CompareTableFromDocumentWithCreatingTable/result.docx";
            IComparisonDocument result = compareResult.GetDocument();
            Stream resultStream        = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Docx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to document with the following source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
Example #3
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("");
        }
Example #4
0
        public static void CompareTwoCreatingTables()
        {
            // Creating Tables
            IComparisonTable     sourceTable = new ComparisonTable(new double[] { 100, 100 }, new double[] { 20, 20 });
            IComparisonParagraph paragraph   = sourceTable.Rows[0].Cells[0].AddParagraph();

            paragraph.AddRun("This is cell.");
            paragraph = sourceTable.Rows[0].Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell of source table.");
            paragraph = sourceTable.Rows[1].Cells[0].AddParagraph();
            paragraph.AddRun("This is Cel of tble.");
            Console.WriteLine("New Table was created.");

            IComparisonTable targetTable = new ComparisonTable(new double[] { 100, 100 }, new double[] { 20, 20 });

            paragraph = targetTable.Rows[0].Cells[0].AddParagraph();
            paragraph.AddRun("This is cell.");
            paragraph = targetTable.Rows[0].Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell of target table.");
            paragraph = targetTable.Rows[1].Cells[0].AddParagraph();
            paragraph.AddRun("This is Cell of table.");
            Console.WriteLine("New Table was created.");

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

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

            // Saving result of comparison to new document
            string resultPath          = @"./../../Components/testresult/CompareTwoCreatingTables/result.docx";
            IComparisonDocument result = compareResult.GetDocument();
            Stream resultStream        = new FileStream(resultPath, FileMode.Create);

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