public void Commit()
        {
            foreach (var rng in _cellRange)
            {
                if (rng.IsValid)
                {
                    // get cell style
                    var            row            = _flex.Rows[rng.Row] as ExcelRow;
                    var            col            = _flex.Columns[rng.Column];
                    ExcelCellStyle excelCellStyle = new ExcelCellStyle();
                    if (row != null)
                    {
                        var cs = row.GetCellStyle(col) as ExcelCellStyle;
                        if (cs != null)
                        {
                            excelCellStyle = cs;
                        }
                    }
                    excelCellStyle.Format = NoDecimalPlacesList.Contains(SelectedNumberFormat)
                        ? SelectedNumberFormat.Format
                        : SelectedNumberFormat.Format + ((NumberFormat)SelectedNumberFormat).DecimalPlaces;

                    row.SetCellStyle(_flex.Columns[rng.Column], excelCellStyle);
                    _flex.Invalidate(rng);
                }
            }
        }
        private void InitialNumberFormats()
        {
            NumberFormat generalFormat = new NumberFormat();

            generalFormat.Name             = "General";
            generalFormat.Format           = "G";
            generalFormat.PropertyChanged += generalFormat_PropertyChanged;
            NoDecimalPlacesList.Add(generalFormat);
            NumberFormats.Add(generalFormat);

            NumberFormat numberFormat = new NumberFormat();

            numberFormat.Name             = "Number";
            numberFormat.Format           = "N";
            numberFormat.PropertyChanged += generalFormat_PropertyChanged;
            NumberFormats.Add(numberFormat);

            NumberFormat currencyFormat = new NumberFormat();

            currencyFormat.Name             = "Currency";
            currencyFormat.Format           = "C";
            currencyFormat.PropertyChanged += generalFormat_PropertyChanged;
            NumberFormats.Add(currencyFormat);

            NumberFormat percentFormat = new NumberFormat();

            percentFormat.Name             = "Percentage";
            percentFormat.Format           = "P";
            percentFormat.PropertyChanged += generalFormat_PropertyChanged;
            NumberFormats.Add(percentFormat);

            NumberFormat exponentialFormat = new NumberFormat();

            exponentialFormat.Name             = "Scientific";
            exponentialFormat.Format           = "E";
            exponentialFormat.PropertyChanged += generalFormat_PropertyChanged;
            NumberFormats.Add(exponentialFormat);

            DateFormat dateFormat = new DateFormat();

            dateFormat.Name             = "Date";
            dateFormat.Format           = "f";
            dateFormat.PropertyChanged += generalFormat_PropertyChanged;
            NumberFormats.Add(dateFormat);
            NoDecimalPlacesList.Add(dateFormat);


            SelectedNumberFormat = generalFormat;

            var cell = _cellRange.FirstOrDefault();
            var row  = _flex.Rows[cell.Row] as ExcelRow;
            var col  = _flex.Columns[cell.Column];

            FormatBase defaultFormat = generalFormat;

            if (row != null)
            {
                var cs = row.GetCellStyle(col) as ExcelCellStyle;
                var cv = row.GetValue(col);
                defaultFormat = GetNumberFormat(cs != null ? cs.Format : null, cv);
            }
            SelectedNumberFormat = defaultFormat;
            SelectedNumberFormat.PropertyChanged += SelectedNumberFormat_PropertyChanged;

            InvalidateText();
        }