private static void Compare(string fileName, CellsComparisonSettings settings)
        {
            string target_settings_file_name = "GroupDocs.Comparison.Samples.Cells.data.settings_target.xlsx";

            string source_settings_file_name = "GroupDocs.Comparison.Samples.Cells.data.settings_source.xlsx";

            var assembly = Assembly.GetExecutingAssembly();

            var source_settings_file = assembly.GetManifestResourceStream(source_settings_file_name);

            var target_settings_file = assembly.GetManifestResourceStream(target_settings_file_name);

            ComparisonWorkbookBase source = new ComparisonWorkbook(source_settings_file);
            ComparisonWorkbookBase target = new ComparisonWorkbook(target_settings_file);
            var watch = new Stopwatch();

            watch.Start();

            var result = source.CompareWith(target, settings);

            Console.WriteLine("Saving result to file");

            result.GetWorkbook().Save(fileName);
            watch.Stop();

            Console.WriteLine("Compared for " + watch.ElapsedMilliseconds / 1000 + " seconds\n\n");
        }
        public static void CompareWithDefaultSettings()
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparison of documents with default settings has been started");
            Compare("../../testresult/settings/Default settings/save.xlsx", settings);
        }
        public static void HideDeletedContent()
        {
            var settings = new CellsComparisonSettings();

            settings.ShowDeletedContent = false;

            Console.WriteLine("Comparison of documents without showing deleted content has been started");
            Compare("../../testresult/settings/Hide deleted content/save.xlsx", settings);
        }
        public static void DisableSummaryPageGeneration()
        {
            var settings = new CellsComparisonSettings();

            settings.GenerateSummaryPage = false;

            Console.WriteLine("Comparison of documents without summary page generation has been started");
            Compare("../../testresult/settings/Disable summary page/save.xlsx", settings);
        }
        public static void SetSeparationCharsForText()
        {
            var settings = new CellsComparisonSettings();

            settings.WordsSeparatorChars = new[] { '/', '|', ' ' };

            Console.WriteLine("Comparison of documents with text separation chars settings has been started");
            Compare("../../testresult/settings/Separation chars/save.xlsx", settings);
        }
Exemplo n.º 6
0
        public static void CompareCellsOnTheSameWorkbook(ComparisonWorkbookBase source, string filename)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two cells on the same workbook and the same worksheet");
            var result = source.Worksheets[0].CellRange["A1"].CompareWith(source.Worksheets[0].CellRange["B1"], settings);

            Console.WriteLine("Comparison Done. Creating a file with result changes");
            result.GetWorkbook().Save(filename);
            Console.WriteLine("File with result changes was successfully created\n\n");
        }
Exemplo n.º 7
0
        public static void CompareErrorCellWithNonError(ComparisonWorkbookBase source, ComparisonWorkbookBase target,
                                                        string filename)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two cells on different workbook where source and target cells contain plain text");
            var result = source.Worksheets[0].CellRange["A6"].CompareWith(target.Worksheets[0].CellRange["A6"], settings);

            Console.WriteLine("Comparison Done. Creating a file with result changes");
            result.GetWorkbook().Save(filename);
            Console.WriteLine("File with result changes was successfully created\n\n");
        }
        public static void CompareWorksheetsFromOneDocuments(ComparisonWorkbookBase source, string filePath, string imagePath)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two worksheet from one workbook");
            var result = source.Worksheets[1].CompareWith(source.Worksheets[2], settings);

            Console.WriteLine("Worksheets were successfully compared");
            result.GetWorkbook().Save(filePath);
            Console.WriteLine("Results were successfully saved to a file");
            result.GetWorkbook().SaveAsImages(imagePath);
            Console.WriteLine("Results were successfully saved to a bunch of images\n\n");
        }
        public static void SetPropertiesForInsertedComponents()
        {
            var settings = new CellsComparisonSettings();

            settings.InsertedItemsStyle.Color        = Color.Cyan;
            settings.InsertedItemsStyle.IsBold       = true;
            settings.InsertedItemsStyle.IsItalic     = true;
            settings.InsertedItemsStyle.IsStrikeout  = true;
            settings.InsertedItemsStyle.IsUnderlined = true;

            Console.WriteLine("Comparison of documents with settings for inserted content has been started");
            Compare("../../testresult/settings/Inserted properties/save.xlsx", settings);
        }
        public static void SetSeparatorsForDeletedAndAddedComponents()
        {
            var settings = new CellsComparisonSettings();

            settings.DeletedItemsStyle.BeginSeparatorString = "<";
            settings.DeletedItemsStyle.EndSeparatorString   = ">";

            settings.InsertedItemsStyle.BeginSeparatorString = "|";
            settings.InsertedItemsStyle.EndSeparatorString   = "|";

            Console.WriteLine("Comparison of documents with separators for deleted and added content has been started");
            Compare("../../testresult/settings/Separators/save.xlsx", settings);
        }
Exemplo n.º 11
0
        public static void CompareTwoWorkbooks(ComparisonWorkbookBase source, ComparisonWorkbookBase target, string filePath,
                                               string imagePath)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two workbooks with the same quantity of worksheets");
            var result = source.CompareWith(target, settings);

            Console.WriteLine("Workbooks were successfully compared");
            result.GetWorkbook().Save(filePath);
            Console.WriteLine("Results were successfully saved to file");
            result.GetWorkbook().SaveAsImages(imagePath);
            Console.WriteLine("Results were successfully saved to a bunch of images\n\n");
        }
        public static void CompareWorksheetsWithDifferentContent(ComparisonWorkbookBase source, ComparisonWorkbookBase target,
                                                                 string filePath, string imagePath)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two worksheet with different content");
            var result = source.Worksheets[3].CompareWith(target.Worksheets[3], settings);

            Console.WriteLine("Worksheets were successfully compared");
            result.GetWorkbook().Save(filePath);
            Console.WriteLine("Results were successfully saved to a file");
            result.GetWorkbook().SaveAsImages(imagePath);
            Console.WriteLine("Results were successfully saved to a bunch of images\n\n");
        }
Exemplo n.º 13
0
        public static void CompareTwoWorkbooksWithDeletedAndAddedWorksheets(ComparisonWorkbookBase source,
                                                                            ComparisonWorkbookBase target, string filePath, string imagePath)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine(
                "Comparing two workbooks where both of them contain worksheets that are not presented in the opponent document");
            var result = source.CompareWith(target, settings);

            Console.WriteLine("Workbooks were successfully compared");
            result.GetWorkbook().Save(filePath);
            Console.WriteLine("Results were successfully saved to file");
            result.GetWorkbook().SaveAsImages(imagePath);
            Console.WriteLine("Results were successfully saved to a bunch of images\n\n");
        }
Exemplo n.º 14
0
        public static void CompareTwoWorkbooksWithDeletedWorksheets(ComparisonWorkbookBase source, ComparisonWorkbookBase target,
                                                                    string filePath, string imagePath)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine(
                "Comparing two workbooks where target document doesn't contain some worksheets from source workbook");
            var result = source.CompareWith(target, settings);

            Console.WriteLine("Workbooks were successfully compared");
            result.GetWorkbook().Save(filePath);
            Console.WriteLine("Results were successfully saved to file");
            result.GetWorkbook().SaveAsImages(imagePath);
            Console.WriteLine("Results were successfully saved to a bunch of images\n\n");
        }
        public static void CompareEmptyWorksheetWithNotEmpty(ComparisonWorkbookBase source, ComparisonWorkbookBase target,
                                                             string filePath, string imagePath)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two worksheet first worksheet is empty");
            var result = source.Worksheets[3].CompareWith(target.Worksheets[1], settings);

            Console.WriteLine("Worksheets were successfully compared");
            ComparisonWorkbookBase workbook = result.GetWorkbook();

            workbook.Save(filePath);
            Console.WriteLine("Results were successfully saved to a file");
            //result.GetWorkbook().SaveAsImages(imagePath);
            Console.WriteLine("Results were successfully saved to a bunch of images\n\n");
        }
        public static void SetStylePropertiesForDeletedComponents()
        {
            var settings = new CellsComparisonSettings
            {
                DeletedItemsStyle =
                {
                    Color        = Color.DarkGreen,
                    IsBold       = true,
                    IsItalic     = true,
                    IsStrikeout  = true,
                    IsUnderlined = true
                }
            };

            Console.WriteLine("Comparison of documents with settings for deleted content has been started");
            Compare("../../testresult/settings/Deleted properties/save.xlsx", settings);
        }
Exemplo n.º 17
0
        public static void CompareTwoBigWorkbooks(ComparisonWorkbookBase source, ComparisonWorkbookBase target, string filePath
                                                  /*, string imagePath*/)
        {
            var settings = new CellsComparisonSettings();

            Console.WriteLine("Comparing two workbooks with big amount of worksheet and cells in there");
            Stopwatch watch = new Stopwatch();

            watch.Start();
            var result = source.CompareWith(target, settings);

            Console.WriteLine("Workbooks were successfully compared");
            result.GetWorkbook().Save(filePath);
            Console.WriteLine("Results were successfully saved to file");

            watch.Stop();
            Console.WriteLine("Compared for - " + watch.ElapsedMilliseconds + "milliseconds\n\n");
        }