Exemplo n.º 1
0
        internal SLCellFormula Clone()
        {
            var cf = new SLCellFormula();

            cf.FormulaText          = FormulaText;
            cf.FormulaType          = FormulaType;
            cf.AlwaysCalculateArray = AlwaysCalculateArray;
            cf.Reference            = Reference;
            cf.DataTable2D          = DataTable2D;
            cf.DataTableRow         = DataTableRow;
            cf.Input1Deleted        = Input1Deleted;
            cf.Input2Deleted        = Input2Deleted;
            cf.R1            = R1;
            cf.R2            = R2;
            cf.CalculateCell = CalculateCell;
            cf.SharedIndex   = SharedIndex;
            cf.Bx            = Bx;

            return(cf);
        }
Exemplo n.º 2
0
        internal void FromCell(Cell c)
        {
            SetAllNull();

            //if (c.CellFormula != null) this.Formula = (CellFormula)c.CellFormula.CloneNode(true);
            if (c.CellFormula != null)
            {
                CellFormula = new SLCellFormula();
                CellFormula.FromCellFormula(c.CellFormula);
            }

            if (c.StyleIndex != null)
            {
                StyleIndex = c.StyleIndex.Value;
            }

            if (c.DataType != null)
            {
                DataType = c.DataType.Value;
            }
            else
            {
                DataType = CellValues.Number;
            }

            if (c.CellValue != null)
            {
                CellText = c.CellValue.Text ?? string.Empty;
            }

            double fValue = 0;
            var    iValue = 0;
            var    bValue = false;

            switch (DataType)
            {
            case CellValues.Number:
                if (double.TryParse(CellText, NumberStyles.Any, CultureInfo.InvariantCulture, out fValue))
                {
                    NumericValue = fValue;
                }
                break;

            case CellValues.SharedString:
                if (int.TryParse(CellText, NumberStyles.Any, CultureInfo.InvariantCulture, out iValue))
                {
                    NumericValue = iValue;
                }
                break;

            case CellValues.Boolean:
                if (double.TryParse(CellText, NumberStyles.Any, CultureInfo.InvariantCulture, out fValue))
                {
                    if (fValue > 0.5)
                    {
                        NumericValue = 1;
                    }
                    else
                    {
                        NumericValue = 0;
                    }
                }
                else if (bool.TryParse(CellText, out bValue))
                {
                    if (bValue)
                    {
                        NumericValue = 1;
                    }
                    else
                    {
                        NumericValue = 0;
                    }
                }
                break;
            }

            if (c.CellMetaIndex != null)
            {
                CellMetaIndex = c.CellMetaIndex.Value;
            }
            if (c.ValueMetaIndex != null)
            {
                ValueMetaIndex = c.ValueMetaIndex.Value;
            }
            if (c.ShowPhonetic != null)
            {
                ShowPhonetic = c.ShowPhonetic.Value;
            }
        }