コード例 #1
0
 public override String ToString()
 {
     CellReference cr = new CellReference(Row, Column);
     StringBuilder sb = new StringBuilder();
     sb.Append(GetType().Name).Append("[");
     sb.Append(_evaluator.SheetName);
     sb.Append('!');
     sb.Append(cr.FormatAsString());
     sb.Append("]");
     return sb.ToString();
 }
コード例 #2
0
ファイル: Ref3DPtg.cs プロジェクト: Johnnyfly/source20131023
 public override String ToString()
 {
     CellReference cr = new CellReference(Row, Column, !IsRowRelative, !IsColRelative);
     StringBuilder sb = new StringBuilder();
     sb.Append(GetType().Name);
     sb.Append(" [");
     sb.Append("sheetIx=").Append(ExternSheetIndex);
     sb.Append(" ! ");
     sb.Append(cr.FormatAsString());
     sb.Append("]");
     return sb.ToString();
 }
コード例 #3
0
        /**
     * @return the text format of this range using specified sheet name.
     */
        public String FormatAsString(String sheetName, bool useAbsoluteAddress)
        {
            StringBuilder sb = new StringBuilder();
            if (sheetName != null)
            {
                sb.Append(SheetNameFormatter.Format(sheetName));
                sb.Append("!");
            }
            CellReference cellRefFrom = new CellReference(FirstRow, FirstColumn,
                    useAbsoluteAddress, useAbsoluteAddress);
            CellReference cellRefTo = new CellReference(LastRow, LastColumn,
                    useAbsoluteAddress, useAbsoluteAddress);
            sb.Append(cellRefFrom.FormatAsString());

            //for a single-cell reference return A1 instead of A1:A1
            if (!cellRefFrom.Equals(cellRefTo))
            {
                sb.Append(':');
                sb.Append(cellRefTo.FormatAsString());
            }
            return sb.ToString();
        }
コード例 #4
0
        /**
         * @return the text format of this range using specified sheet name.
         */
        public String FormatAsString(String sheetName, bool useAbsoluteAddress)
        {
            StringBuilder sb = new StringBuilder();

            if (sheetName != null)
            {
                sb.Append(SheetNameFormatter.Format(sheetName));
                sb.Append("!");
            }
            CellReference cellRefFrom = new CellReference(FirstRow, FirstColumn,
                                                          useAbsoluteAddress, useAbsoluteAddress);
            CellReference cellRefTo = new CellReference(LastRow, LastColumn,
                                                        useAbsoluteAddress, useAbsoluteAddress);

            sb.Append(cellRefFrom.FormatAsString());

            //for a single-cell reference return A1 instead of A1:A1
            if (!cellRefFrom.Equals(cellRefTo))
            {
                sb.Append(':');
                sb.Append(cellRefTo.FormatAsString());
            }
            return(sb.ToString());
        }
コード例 #5
0
 public override String ToString()
 {
     CellReference crA = new CellReference(_firstRow, _firstCol);
     CellReference crB = new CellReference(_lastRow, _lastCol);
     return GetType().Name + " [" + crA.FormatAsString() + ":" + crB.FormatAsString() + "]";
 }
コード例 #6
0
ファイル: HSSFCell.cs プロジェクト: Johnnyfly/source20131023
 /// <summary>
 /// Called when this cell is modified.
 /// The purpose of this method is to validate the cell state prior to modification.
 /// </summary>
 internal void NotifyArrayFormulaChanging()
 {
     CellReference ref1 = new CellReference(this);
     String msg = "Cell " + ref1.FormatAsString() + " is part of a multi-cell array formula. " +
             "You cannot change part of an array.";
     NotifyArrayFormulaChanging(msg);
 }
コード例 #7
0
        /// <summary>
        /// Sets the print area.
        /// </summary>
        /// <param name="sheetIndex">Zero-based sheet index (0 = First Sheet)</param>
        /// <param name="startColumn">Column to begin printarea</param>
        /// <param name="endColumn">Column to end the printarea</param>
        /// <param name="startRow">Row to begin the printarea</param>
        /// <param name="endRow">Row to end the printarea</param>
        public void SetPrintArea(int sheetIndex, int startColumn, int endColumn,
                                  int startRow, int endRow)
        {

            //using absolute references because they don't Get copied and pasted anyway
            CellReference cell = new CellReference(startRow, startColumn, true, true);
            String reference = cell.FormatAsString();

            cell = new CellReference(endRow, endColumn, true, true);
            reference = reference + ":" + cell.FormatAsString();

            SetPrintArea(sheetIndex, reference);
        }
コード例 #8
0
 public override String ToString()
 {
     CellReference crA = new CellReference(FirstRow, FirstColumn);
     CellReference crB = new CellReference(LastRow, LastColumn);
     StringBuilder sb = new StringBuilder();
     sb.Append(GetType().Name).Append("[");
     sb.Append(_evaluator.SheetName);
     sb.Append('!');
     sb.Append(crA.FormatAsString());
     sb.Append(':');
     sb.Append(crB.FormatAsString());
     sb.Append("]");
     return sb.ToString();
 }
コード例 #9
0
        protected String FormatReferenceAsString()
        {
            CellReference topLeft = new CellReference(FirstRow, FirstColumn, !IsFirstRowRelative, !IsFirstColRelative);
            CellReference botRight = new CellReference(LastRow, LastColumn, !IsLastRowRelative, !IsLastColRelative);

            if (AreaReference.IsWholeColumnReference(topLeft, botRight))
            {
                return (new AreaReference(topLeft, botRight)).FormatAsString();
            }
            return topLeft.FormatAsString() + ":" + botRight.FormatAsString();
        }
コード例 #10
0
 public override String ToString()
 {
     StringBuilder sb = new StringBuilder(64);
     CellReference crA = new CellReference(_firstRowIndex, _firstColumnIndex, false, false);
     CellReference crB = new CellReference(_lastRowIndex, _lastColumnIndex, false, false);
     sb.Append(GetType().Name);
     sb.Append(" [").Append(crA.FormatAsString()).Append(':').Append(crB.FormatAsString()).Append("]");
     return sb.ToString();
 }
コード例 #11
0
 public String FormatReferenceAsString()
 {
     // Only make cell references as needed. Memory is an issue
     CellReference cr = new CellReference(Row, Column, !IsRowRelative, !IsColRelative);
     return cr.FormatAsString();
 }
コード例 #12
0
ファイル: Address.cs プロジェクト: Johnnyfly/source20131023
        public ValueEval Evaluate(ValueEval[] args, int srcRowIndex,
                                  int srcColumnIndex)
        {
            if (args.Length < 2 || args.Length > 5)
            {
                return ErrorEval.VALUE_INVALID;
            }
            try
            {
                bool pAbsRow, pAbsCol;

                int row = (int)NumericFunction.SingleOperandEvaluate(args[0], srcRowIndex, srcColumnIndex);
                int col = (int)NumericFunction.SingleOperandEvaluate(args[1], srcRowIndex, srcColumnIndex);

                int refType;
                if (args.Length > 2)
                {
                    refType = (int)NumericFunction.SingleOperandEvaluate(args[2], srcRowIndex, srcColumnIndex);
                }
                else
                {
                    refType = REF_ABSOLUTE;
                }
                switch (refType)
                {
                    case REF_ABSOLUTE:
                        pAbsRow = true;
                        pAbsCol = true;
                        break;
                    case REF_ROW_ABSOLUTE_COLUMN_RELATIVE:
                        pAbsRow = true;
                        pAbsCol = false;
                        break;
                    case REF_ROW_RELATIVE_RELATIVE_ABSOLUTE:
                        pAbsRow = false;
                        pAbsCol = true;
                        break;
                    case REF_RELATIVE:
                        pAbsRow = false;
                        pAbsCol = false;
                        break;
                    default:
                        throw new EvaluationException(ErrorEval.VALUE_INVALID);
                }

                bool a1;
                if (args.Length > 3)
                {
                    ValueEval ve = OperandResolver.GetSingleValue(args[3], srcRowIndex, srcColumnIndex);
                    // TODO R1C1 style is not yet supported
                    a1 = ve == MissingArgEval.instance ? true : OperandResolver.CoerceValueToBoolean(ve, false).Value;
                }
                else
                {
                    a1 = true;
                }

                String sheetName;
                if (args.Length == 5)
                {
                    ValueEval ve = OperandResolver.GetSingleValue(args[4], srcRowIndex, srcColumnIndex);
                    sheetName = ve == MissingArgEval.instance ? null : OperandResolver.CoerceValueToString(ve);
                }
                else
                {
                    sheetName = null;
                }

                CellReference ref1 = new CellReference(row - 1, col - 1, pAbsRow, pAbsCol);
                StringBuilder sb = new StringBuilder(32);
                if (sheetName != null)
                {
                    SheetNameFormatter.AppendFormat(sb, sheetName);
                    sb.Append('!');
                }
                sb.Append(ref1.FormatAsString());

                return new StringEval(sb.ToString());

            }
            catch (EvaluationException e)
            {
                return e.GetErrorEval();
            }
        }