public void ReplaceChars(IRibbonControl ribbonControl)
        {
            var replacer = GetService <ICyrillicLettersReplacer>();

            Range selection = GetSelectionOrUsedRange(App.ActiveSheet);

            selection.ApplyForEachCellOfType <string, object>(
                value =>
            {
                var newValue = replacer.ReplaceCyrillicCharsWithLatin(value);
                return((object)newValue ?? value);
            });
        }
        public void Transliterate(IRibbonControl ribbonControl)
        {
            var transliterator = GetService <ITransliterator>();

            Range selection = GetSelectionOrUsedRange(App.ActiveSheet);

            selection.ApplyForEachCellOfType <string, object>(
                value =>
            {
                var newValue = transliterator.Transliterate(value);
                return((object)newValue ?? value);
            });
        }
        private void StringifyNumerics(SupportedCulture supportedCulture)
        {
            var stringifier = Container.ResolveKeyed <INumericStringifier>(supportedCulture);

            Range selection = GetSelectionOrUsedRange(App.ActiveSheet);

            selection.ApplyForEachCellOfType <double, object>(
                value =>
            {
                var newValue = stringifier.StringifyNumber(value);
                return((object)newValue ?? value);
            });
        }
예제 #4
0
 public void Parse(Range selection)
 {
     selection.ApplyForEachCellOfType <string, object>(
         value =>
     {
         var newValue = value.ParseDecimal();
         if (newValue.HasValue)
         {
             // Excel stores numerics as Double
             return((object)Convert.ToDouble(newValue));
         }
         return((object)value);
     });
 }
        public void RemoveAllSpaces(Range range)
        {
            logger.Info($"Trim spaces for range {range.GetRelativeAddress()}");

            range.ApplyForEachCellOfType <string, string>(value =>
            {
                if (string.IsNullOrWhiteSpace(value))
                {
                    return(null);
                }

                return(new string(value.Where(c => !char.IsWhiteSpace(c)).ToArray()));
            });
        }
예제 #6
0
        public void ToggleCase(Range range)
        {
            var cells = range.Cast <Range>();

            var firstValue = cells
                             .FirstOrDefault(CheckForLetters)?
                             .Value
                             .ToString();

            if (string.IsNullOrEmpty(firstValue))
            {
                return;
            }

            var targertCase = DetectTargetCase((string)firstValue);

            range.ApplyForEachCellOfType <string, string>(value => ConvertTextCase(value, targertCase));
        }
        public void TrimSpaces(Range range)
        {
            logger.Info($"Trim spaces for range {range.GetRelativeAddress()}");

            range.ApplyForEachCellOfType <string, string>(value => value.TrimSpaces());
        }