private ExcelSheetDiff ExecuteDiff2(ExcelSheet srcSheet, ExcelSheet dstSheet)
        {
            ExcelSheetDiff diff = null;

            diff = ExcelSheet.Diff(srcSheet, dstSheet, diffConfig);
            return(diff);
        }
        public DiffGridModel(ExcelSheetDiff sheetDiff, DiffType type) : base()
        {
            DiffType  = type;
            SheetDiff = sheetDiff;

            columnCount = SheetDiff.Rows.Any() ? SheetDiff.Rows.Max(r => r.Value.Cells.Count) : 0;
            rowCount    = SheetDiff.Rows.Count();

            App.Instance.OnSettingUpdated += () => { InvalidateAll(); };
        }
Exemple #3
0
        public void AddSheetDiff(ExcelSheetDiff diff)
        {
            if (SheetDiffInfoList
                .Any(i => i.SheetDiff.SrcSheet.Name == diff.SrcSheet.Name && i.SheetDiff.DstSheet.Name == diff.DstSheet.Name))
            {
                return;
            }

            SheetDiffInfoList.Add(new ExcelSheetDiffInfo(diff));
        }
Exemple #4
0
        private ExcelSheetDiff ExecuteDiff(ExcelSheet srcSheet, ExcelSheet dstSheet)
        {
            ExcelSheetDiff diff = null;

            ProgressWindow.DoWorkWithModal(progress =>
            {
                progress.Report(Properties.Resources.Msg_ExtractingDiff);
                diff = ExcelSheetDiff.Diff(srcSheet, dstSheet, diffConfig);
            });

            return(diff);
        }
Exemple #5
0
        public DiffGridModel(DiffType type, ExcelSheetDiff sheetDiff, DiffGridModelConfig config) : base()
        {
            SheetDiff         = sheetDiff;
            Config            = config;
            ColumnHeaderIndex = Config.ColumnHeaderIndex;
            RowHeaderIndex    = Config.RowHeaderIndex;
            DiffType          = type;

            columnCount = SheetDiff.Rows.Max(r => r.Value.Cells.Count);
            rowCount    = SheetDiff.Rows.Count();

            App.Instance.OnSettingUpdated += () => { NotifyRefresh(); };
        }
Exemple #6
0
        private void ExecuteDiff(bool isStartup = false)
        {
            if (!File.Exists(SrcPathTextBox.Text) || !File.Exists(DstPathTextBox.Text))
            {
                return;
            }

            var args = new DiffViewEventArgs <FastGridControl>(null, container, TargetType.First);

            DataGridEventDispatcher.Instance.DispatchPreExecuteDiffEvent(args);

            var srcPath = SrcPathTextBox.Text;
            var dstPath = DstPathTextBox.Text;

            Debug.Assert(Path.GetExtension(srcPath) == Path.GetExtension(dstPath), $"Compared files should have the same extension.");

            var workbooks   = ReadWorkbooks();
            var srcWorkbook = workbooks.Item1;
            var dstWorkbook = workbooks.Item2;

            DstSheetCombobox.SelectedIndex = SrcSheetCombobox.SelectedIndex;

            // SrcSheetCombobox.SelectedIndex = diffConfig.SrcSheetIndex;
            // DstSheetCombobox.SelectedIndex = diffConfig.DstSheetIndex;

            srcSheetName = SrcSheetCombobox.SelectedItem.ToString();
            dstSheetName = DstSheetCombobox.SelectedItem.ToString();

            var srcSheet = srcWorkbook.Sheets[srcSheetName];
            var dstSheet = dstWorkbook.Sheets[dstSheetName];

            SourceSheet = srcSheet;
            DestSheet   = dstSheet;

            LeftWorkbook  = srcWorkbook;
            RightWorkbook = dstWorkbook;

            if (srcSheet.Rows.Count > 10000 || dstSheet.Rows.Count > 10000)
            {
                MessageBox.Show(Properties.Resources.Msg_WarnSize);
            }

            SheetDiff = ExecuteDiff(srcSheet, dstSheet);

            RefreshBySheet(isStartup);
        }
Exemple #7
0
 public ExcelSheetDiffInfo(ExcelSheetDiff sheetDiff)
 {
     SheetDiff = sheetDiff;
 }
        private void ExecuteDiff(bool isStartup = false)
        {
            if (!File.Exists(SrcPathTextBox.Text) || !File.Exists(DstPathTextBox.Text))
            {
                return;
            }

            SrcDataGrid.ScrollIntoView(FastGridCellAddress.Empty);
            DstDataGrid.ScrollIntoView(FastGridCellAddress.Empty);

            SrcDataGrid.FirstVisibleColumnScrollIndex = 0;
            SrcDataGrid.FirstVisibleRowScrollIndex    = 0;
            DstDataGrid.FirstVisibleColumnScrollIndex = 0;
            DstDataGrid.FirstVisibleRowScrollIndex    = 0;

            SrcDataGrid.InitializeComponent();
            DstDataGrid.InitializeComponent();

            SrcDataGrid.SetMaxColumnSize(App.Instance.Setting.CellWidth);
            DstDataGrid.SetMaxColumnSize(App.Instance.Setting.CellWidth);
            SrcDataGrid.SetMinColumnSize(App.Instance.Setting.CellWidth);
            DstDataGrid.SetMinColumnSize(App.Instance.Setting.CellWidth);

            var           srcPath = SrcPathTextBox.Text;
            var           dstPath = DstPathTextBox.Text;
            ExcelWorkbook wb1     = null;
            ExcelWorkbook wb2     = null;

            ProgressWindow.DoWorkWithModal(progress =>
            {
                progress.Report(Properties.Resources.Msg_ReadingFiles);

                var config = CreateReadConfig();
                wb1        = ExcelWorkbook.Create(srcPath, config);
                wb2        = ExcelWorkbook.Create(dstPath, config);
            });

            FileSetting srcSetting = null;
            FileSetting dstSetting = null;

            if (!IgnoreFileSettingCheckbox.IsChecked.Value)
            {
                srcSetting =
                    FindFilseSetting(Path.GetFileName(SrcPathTextBox.Text), SrcSheetCombobox.SelectedIndex, SrcSheetCombobox.SelectedItem.ToString(), isStartup);

                dstSetting =
                    FindFilseSetting(Path.GetFileName(DstPathTextBox.Text), DstSheetCombobox.SelectedIndex, DstSheetCombobox.SelectedItem.ToString(), isStartup);

                diffConfig = CreateDiffConfig(srcSetting, dstSetting, isStartup);
            }
            else
            {
                diffConfig = new ExcelSheetDiffConfig();

                diffConfig.SrcSheetIndex = Math.Max(SrcSheetCombobox.SelectedIndex, 0);
                diffConfig.DstSheetIndex = Math.Max(DstSheetCombobox.SelectedIndex, 0);
            }

            SrcSheetCombobox.SelectedIndex = diffConfig.SrcSheetIndex;
            DstSheetCombobox.SelectedIndex = diffConfig.DstSheetIndex;

            var sheet1 = wb1.Sheets[SrcSheetCombobox.SelectedItem.ToString()];
            var sheet2 = wb2.Sheets[DstSheetCombobox.SelectedItem.ToString()];

            if (sheet1.Rows.Count > 10000 || sheet2.Rows.Count > 10000)
            {
                MessageBox.Show(Properties.Resources.Msg_WarnSize);
            }

            ExcelSheetDiff diff = null;

            ProgressWindow.DoWorkWithModal(progress =>
            {
                progress.Report(Properties.Resources.Msg_ExtractingDiff);
                diff = ExcelSheet.Diff(sheet1, sheet2, diffConfig);
            });

            var modelConfig = new DiffGridModelConfig();
            var srcModel    = new DiffGridModel(DiffType.Source, diff, modelConfig);
            var dstModel    = new DiffGridModel(DiffType.Dest, diff, modelConfig);

            (DataContext as ViewModels.DiffViewModel).UpdateDiffSummary(diff.CreateSummary());

            SrcDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors;
            DstDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors;
            SrcDataGrid.CellFontName      = App.Instance.Setting.FontName;
            DstDataGrid.CellFontName      = App.Instance.Setting.FontName;

            SrcDataGrid.Model = srcModel;
            DstDataGrid.Model = dstModel;

            if (ShowOnlyDiffRadioButton.IsChecked.Value)
            {
                srcModel.HideEqualRows();
                srcModel.HideEqualRows();
            }

            if (srcSetting != null)
            {
                srcModel.SetColumnHeader(srcSetting.ColumnHeaderIndex);
                if (string.IsNullOrEmpty(srcSetting.RowHeaderName))
                {
                    srcModel.SetRowHeader(srcSetting.RowHeaderIndex);
                }
                else
                {
                    srcModel.SetRowHeader(srcSetting.RowHeaderName);
                }
                SrcDataGrid.MaxRowHeaderWidth = srcSetting.MaxRowHeaderWidth;
            }

            if (dstSetting != null)
            {
                dstModel.SetColumnHeader(dstSetting.ColumnHeaderIndex);
                if (string.IsNullOrEmpty(dstSetting.RowHeaderName))
                {
                    dstModel.SetRowHeader(dstSetting.RowHeaderIndex);
                }
                else
                {
                    dstModel.SetRowHeader(dstSetting.RowHeaderName);
                }
                DstDataGrid.MaxRowHeaderWidth = dstSetting.MaxRowHeaderWidth;
            }

            DataGridEventDispatcher.DispatchModelUpdateEvent(SrcDataGrid, container);
            DataGridEventDispatcher.DispatchModelUpdateEvent(DstDataGrid, container);

            if (!App.Instance.KeepFileHistory)
            {
                App.Instance.UpdateRecentFiles(SrcPathTextBox.Text, DstPathTextBox.Text);
            }
        }