Ejemplo n.º 1
0
        private void _btnReplaceAll_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(_comboFind.Text))
            {
                return;
            }
            if (!_comboReplace.Items.Contains(_comboReplace.Text))
            {
                _comboReplace.Items.Add(_comboReplace.Text);
            }

            _dataGrid.Items.Clear();

            List <FindResult> results = _owner.FindAll(_comboFind.Text, _option);

            foreach (FindResult result in results)
            {
                if (result.Sheet.IsProtected)
                {
                    continue;
                }
                var grid = result.Sheet.Grid;
                if (result.Sheet != _owner.Sheets.SelectedSheet)
                {
                    _owner.Sheets.SelectedSheet = result.Sheet;
                }
                grid = _owner;

                foreach (CellRange cellRange in result.Cells)
                {
                    Replace(cellRange);
                    string original = null;

                    if (grid[cellRange.Row, cellRange.Column] != null)
                    {
                        original = grid[cellRange.Row, cellRange.Column].ToString();
                    }
                    if (!String.IsNullOrEmpty(original))
                    {
                        CustomFindResult customResult = new CustomFindResult(result.Sheet.SheetName, _owner.GetAddress(cellRange, false), original, cellRange);
                        _dataGrid.Items.Add(customResult);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void _btnFindAll_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(_comboFind.Text))
            {
                return;
            }
            if (!_comboFind.Items.Contains(_comboFind.Text))
            {
                _comboFind.Items.Add(_comboFind.Text);
            }

            _dataGrid.Items.Clear();

            List <FindResult> results = _owner.FindAll(_comboFind.Text, _option);

            foreach (FindResult result in results)
            {
                var grid = result.Sheet.Grid;
                if (result.Sheet == _owner.Sheets.SelectedSheet)
                {
                    grid = _owner;
                }
                foreach (CellRange cellRange in result.Cells)
                {
                    string original = null;

                    if (grid[cellRange.Row, cellRange.Column] != null)
                    {
                        original = grid[cellRange.Row, cellRange.Column].ToString();
                    }
                    if (!String.IsNullOrEmpty(original))
                    {
                        CustomFindResult customResult = new CustomFindResult(result.Sheet.SheetName, _owner.GetAddress(cellRange, false), original, cellRange);
                        _dataGrid.Items.Add(customResult);
                    }
                }
            }

            // To show the datagrid.
            if (_dataGrid.Items.Count > 0)
            {
                Height = Height < 350 ? 350 : Height;
            }
        }