Esempio n. 1
0
        protected void CalcBounds(TOneCellValue aRange)
        {
            TValueAndXF val = new TValueAndXF();

            val.Workbook = aRange.Workbook;
            aRange.Evaluate(0, 0, 0, 0, val);

            TXlsNamedRange XlsRange = val.Workbook.GetNamedRange(FlxConvert.ToString(val.Value), -1, val.Workbook.ActiveSheet);

            if (XlsRange == null)
            {
                XlsRange = val.Workbook.GetNamedRange(FlxConvert.ToString(val.Value), -1, 0);
            }

            if (XlsRange != null)
            {
                FTop    = XlsRange.Top;
                FLeft   = XlsRange.Left;
                Bottom  = XlsRange.Bottom;
                Right   = XlsRange.Right;
                Sheet1  = XlsRange.SheetIndex;
                Sheet2  = XlsRange.SheetIndex;
                RowAbs1 = false; ColAbs1 = false; RowAbs2 = false; ColAbs2 = false;
                return;
            }


            string[] Addresses = FlxConvert.ToString(val.Value).Split(TFormulaMessages.TokenChar(TFormulaToken.fmRangeSep));
            if (Addresses == null || (Addresses.Length != 2 && Addresses.Length != 1))
            {
                FlxMessages.ThrowException(FlxErr.ErrInvalidRef, FlxConvert.ToString(val.Value));
            }
            TCellAddress FirstCell = new TCellAddress(Addresses[0]);

            if (FirstCell.Sheet == null || FirstCell.Sheet.Length == 0)
            {
                Sheet1 = -1;
            }
            else
            {
                Sheet1 = aRange.Workbook.GetSheetIndex(FirstCell.Sheet);
            }
            FTop  = FirstCell.Row;
            FLeft = FirstCell.Col;

            RowAbs1 = FirstCell.RowAbsolute;
            ColAbs1 = FirstCell.ColAbsolute;

            if (Addresses.Length > 1)
            {
                FirstCell = new TCellAddress(Addresses[1]);
            }
            if (FirstCell.Sheet == null || FirstCell.Sheet.Length == 0)
            {
                Sheet2 = Sheet1;
            }
            else
            {
                Sheet2 = aRange.Workbook.GetSheetIndex(FirstCell.Sheet);
            }
            Bottom  = FirstCell.Row;
            Right   = FirstCell.Col;
            RowAbs2 = FirstCell.RowAbsolute;
            ColAbs2 = FirstCell.ColAbsolute;
        }
Esempio n. 2
0
        private void FillIfListView(TreeNode IfNode)
        {
            string strOpenParen  = TFormulaMessages.TokenString(TFormulaToken.fmOpenParen);
            string strCloseParen = TFormulaMessages.TokenString(TFormulaToken.fmCloseParen);

            TImplementedFunctionList fil = new TImplementedFunctionList();

            foreach (TImplementedFunction fi in fil.Values)
            {
                TreeNode n             = IfNode.Nodes.Add(fi.FunctionName.ToLower());
                string   ParamList     = string.Empty;
                int      MinParamCount = fi.MinArgCount;
                if (MinParamCount <= 0)
                {
                    MinParamCount = 1;
                }
                int    MaxParamCount = fi.MaxArgCount;
                string Optional      = MaxParamCount > MinParamCount ? "..." : "";
                ParamList = strOpenParen.PadRight(strOpenParen.Length + MinParamCount - 1, TFormulaMessages.TokenChar(TFormulaToken.fmFunctionSep)) + Optional + strCloseParen;

                string[] sc = { n.Text + ParamList };
                n.ImageIndex         = imgOneExtra;
                n.SelectedImageIndex = n.ImageIndex;
                n.Tag = sc;
            }
        }