public static void CompareTwoCreatingCells() { // Creating Cells IComparisonCell sourceCell = new ComparisonCell(); IComparisonParagraph paragraph = sourceCell.AddParagraph(); paragraph.AddRun("This is Cell of source table."); Console.WriteLine("New Column was created."); IComparisonCell targetCell = new ComparisonCell(); paragraph = targetCell.AddParagraph(); paragraph.AddRun("This is Cell of target table."); Console.WriteLine("New Column was created."); // Creating settings for comparison of Cells WordsComparisonSettings settings = new WordsComparisonSettings(); // Comparing Cells IWordsCompareResult compareResult = sourceCell.CompareWith(targetCell, settings); Console.WriteLine("Cells was compared."); // Saving result of comparison to new document string resultPath = @"./../../Components/testresult/CompareTwoCreatingCells/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(""); }
public static void CompareColumnFromDocumentWithCreatingColumn() { string sourcePath = @"GroupDocs.Comparison.Samples.Words.Components.data.CompareColumnFromDocumentWithCreatingColumn.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 Column from source document IComparisonColumn sourceColumn = (sourceDocument.Sections[0].Body.GetChildNodes(ComparisonNodeType.Table, false)[0] as IComparisonTable).Columns[0]; // Creating Column IComparisonColumn targetColumn = new ComparisonColumn(100, new double[] { 20, 20, 20 }); IComparisonParagraph paragraph = targetColumn.Cells[0].AddParagraph(); paragraph.AddRun("This is cell."); paragraph = targetColumn.Cells[1].AddParagraph(); paragraph.AddRun("This is Cell of target table."); paragraph = targetColumn.Cells[2].AddParagraph(); paragraph.AddRun("This is Cell."); Console.WriteLine("New Column was created."); // Creating settings for comparison of Columns WordsComparisonSettings settings = new WordsComparisonSettings(); // Comparing Columns IWordsCompareResult compareResult = sourceColumn.CompareWith(targetColumn, settings); Console.WriteLine("Columns was compared."); // Saving result of comparison to new document string resultPath = @"./../../Components/testresult/CompareColumnFromDocumentWithCreatingColumn/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(""); }
public static void CompareParagraphsFromDifferentDocuments() { string sourcePath = @"GroupDocs.Comparison.Samples.Words.Components.data.CompareParagraphsFromDifferentDocuments.source.docx"; string targetPath = @"GroupDocs.Comparison.Samples.Words.Components.data.CompareParagraphsFromDifferentDocuments.target.docx"; // Create to streams of documents Assembly assembly = Assembly.GetExecutingAssembly(); Stream sourceStream = assembly.GetManifestResourceStream(sourcePath); Stream targetStream = assembly.GetManifestResourceStream(targetPath); // Opening two documents IComparisonDocument sourceDocument = new ComparisonDocument(sourceStream); Console.WriteLine("Document with source path: " + sourcePath + " was loaded."); IComparisonDocument targetDocument = new ComparisonDocument(targetStream); Console.WriteLine("Document with source path: " + targetPath + " was loaded."); // Getting first Paragraph from source document IComparisonParagraph sourceParagraph = sourceDocument.Sections[0].Body.GetChildNodes(ComparisonNodeType.Paragraph, false)[0] as IComparisonParagraph; // Getting first Paragraph from target document IComparisonParagraph targetParagraph = targetDocument.Sections[0].Body.GetChildNodes(ComparisonNodeType.Paragraph, false)[0] as IComparisonParagraph; // Creating settings for comparison of Paragraphs WordsComparisonSettings settings = new WordsComparisonSettings(); // Comparing Paragraphs IWordsCompareResult compareResult = sourceParagraph.CompareWith(targetParagraph, settings); Console.WriteLine("Paragraphs was compared."); // Saving result of comparison to new document string resultPath = @"./../../Components/testresult/CompareParagraphsFromDifferentDocuments/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(""); }
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(""); }