Ejemplo n.º 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("");
        }
Ejemplo n.º 2
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("");
        }