Пример #1
0
 public LazyAreaEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex,
         int lastColumnIndex, SheetRangeEvaluator evaluator) :
     base(evaluator, firstRowIndex, firstColumnIndex, lastRowIndex, lastColumnIndex)
 {
     
     _evaluator = evaluator;
 }
Пример #2
0
        public ValueEval GetArea3DEval(Area3DPxg aptg)
        {
            SheetRangeEvaluator sre = CreateExternSheetRefEvaluator(aptg.SheetName, aptg.LastSheetName, aptg.ExternalWorkbookNumber);

            return(new LazyAreaEval(aptg.FirstRow, aptg.FirstColumn,
                                    aptg.LastRow, aptg.LastColumn, sre));
        }
Пример #3
0
        public ValueEval GetAreaEval(int firstRowIndex, int firstColumnIndex,
                                     int lastRowIndex, int lastColumnIndex)
        {
            SheetRangeEvaluator sre = GetRefEvaluatorForCurrentSheet();

            return(new LazyAreaEval(firstRowIndex, firstColumnIndex, lastRowIndex, lastColumnIndex, sre));
        }
Пример #4
0
        public ValueEval GetArea3DEval(Area3DPtg aptg)
        {
            SheetRangeEvaluator sre = CreateExternSheetRefEvaluator(aptg.ExternSheetIndex);

            return(new LazyAreaEval(aptg.FirstRow, aptg.FirstColumn,
                                    aptg.LastRow, aptg.LastColumn, sre));
        }
Пример #5
0
 public LazyRefEval(int rowIndex, int columnIndex, SheetRangeEvaluator sre)
     : base(sre, rowIndex, columnIndex)
 {
     if (sre == null)
     {
         throw new ArgumentException("sre must not be null");
     }
     _evaluator = sre;
 }
Пример #6
0
 public LazyRefEval(int rowIndex, int columnIndex, SheetRangeEvaluator sre)
     :base(sre, rowIndex, columnIndex)
 {
    
     if (sre == null)
     {
         throw new ArgumentException("sre must not be null");
     }
     _evaluator = sre;
 }
Пример #7
0
 public LazyAreaEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex,
                     int lastColumnIndex, SheetRangeEvaluator evaluator) :
     base(evaluator, firstRowIndex, firstColumnIndex, lastRowIndex, lastColumnIndex)
 {
     _evaluator = evaluator;
 }
Пример #8
0
 public LazyAreaEval(AreaI ptg, SheetRangeEvaluator evaluator)
     : base(ptg, evaluator)
 {
     _evaluator = evaluator;
 }
Пример #9
0
 public LazyAreaEval(AreaI ptg, SheetRangeEvaluator evaluator)
     : base(ptg, evaluator)
 {
     
     _evaluator = evaluator;
 }
Пример #10
0
        public ValueEval GetRef3DEval(Ref3DPxg rptg)
        {
            SheetRangeEvaluator sre = CreateExternSheetRefEvaluator(rptg.SheetName, rptg.LastSheetName, rptg.ExternalWorkbookNumber);

            return(new LazyRefEval(rptg.Row, rptg.Column, sre));
        }
Пример #11
0
        public ValueEval GetRef3DEval(Ref3DPtg rptg)
        {
            SheetRangeEvaluator sre = CreateExternSheetRefEvaluator(rptg.ExternSheetIndex);

            return(new LazyRefEval(rptg.Row, rptg.Column, sre));
        }
Пример #12
0
        public ValueEval GetRefEval(int rowIndex, int columnIndex)
        {
            SheetRangeEvaluator sre = GetRefEvaluatorForCurrentSheet();

            return(new LazyRefEval(rowIndex, columnIndex, sre));
        }
Пример #13
0
        /**
         * Resolves a cell or area reference dynamically.
         * @param workbookName the name of the workbook Containing the reference.  If <code>null</code>
         * the current workbook is assumed.  Note - to Evaluate formulas which use multiple workbooks,
         * a {@link CollaboratingWorkbooksEnvironment} must be set up.
         * @param sheetName the name of the sheet Containing the reference.  May be <code>null</code>
         * (when <c>workbookName</c> is also null) in which case the current workbook and sheet is
         * assumed.
         * @param refStrPart1 the single cell reference or first part of the area reference.  Must not
         * be <code>null</code>.
         * @param refStrPart2 the second part of the area reference. For single cell references this
         * parameter must be <code>null</code>
         * @param isA1Style specifies the format for <c>refStrPart1</c> and <c>refStrPart2</c>.
         * Pass <c>true</c> for 'A1' style and <c>false</c> for 'R1C1' style.
         * TODO - currently POI only supports 'A1' reference style
         * @return a {@link RefEval} or {@link AreaEval}
         */
        public ValueEval GetDynamicReference(String workbookName, String sheetName, String refStrPart1,
                                             String refStrPart2, bool isA1Style)
        {
            if (!isA1Style)
            {
                throw new Exception("R1C1 style not supported yet");
            }
            SheetRefEvaluator se = CreateExternSheetRefEvaluator(workbookName, sheetName);

            if (se == null)
            {
                return(ErrorEval.REF_INVALID);
            }
            SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);

            // ugly typecast - TODO - make spReadsheet version more easily accessible
            SpreadsheetVersion ssVersion = ((IFormulaParsingWorkbook)_workbook).GetSpreadsheetVersion();

            NameType part1refType = ClassifyCellReference(refStrPart1, ssVersion);

            switch (part1refType)
            {
            case NameType.BadCellOrNamedRange:
                return(ErrorEval.REF_INVALID);

            case NameType.NamedRange:
                IEvaluationName nm = ((IFormulaParsingWorkbook)_workbook).GetName(refStrPart1, _sheetIndex);
                if (!nm.IsRange)
                {
                    throw new Exception("Specified name '" + refStrPart1 + "' is not a range as expected.");
                }
                return(_bookEvaluator.EvaluateNameFormula(nm.NameDefinition, this));
            }
            if (refStrPart2 == null)
            {
                // no ':'
                switch (part1refType)
                {
                case NameType.Column:
                case NameType.Row:
                    return(ErrorEval.REF_INVALID);

                case NameType.Cell:
                    CellReference cr = new CellReference(refStrPart1);
                    return(new LazyRefEval(cr.Row, cr.Col, sre));
                }
                throw new InvalidOperationException("Unexpected reference classification of '" + refStrPart1 + "'.");
            }
            NameType part2refType = ClassifyCellReference(refStrPart1, ssVersion);

            switch (part2refType)
            {
            case NameType.BadCellOrNamedRange:
                return(ErrorEval.REF_INVALID);

            case NameType.NamedRange:
                throw new Exception("Cannot Evaluate '" + refStrPart1
                                    + "'. Indirect Evaluation of defined names not supported yet");
            }

            if (part2refType != part1refType)
            {
                // LHS and RHS of ':' must be compatible
                return(ErrorEval.REF_INVALID);
            }
            int firstRow, firstCol, lastRow, lastCol;

            switch (part1refType)
            {
            case NameType.Column:
                firstRow = 0;
                if (part2refType.Equals(NameType.Column))
                {
                    lastRow  = ssVersion.LastRowIndex;
                    firstCol = ParseRowRef(refStrPart1);
                    lastCol  = ParseRowRef(refStrPart2);
                }
                else
                {
                    lastRow  = ssVersion.LastRowIndex;
                    firstCol = ParseColRef(refStrPart1);
                    lastCol  = ParseColRef(refStrPart2);
                }
                break;

            case NameType.Row:
                // support of cell range in the form of integer:integer
                firstCol = 0;
                if (part2refType.Equals(NameType.Row))
                {
                    firstRow = ParseColRef(refStrPart1);
                    lastRow  = ParseColRef(refStrPart2);
                    lastCol  = ssVersion.LastColumnIndex;
                }
                else
                {
                    lastCol  = ssVersion.LastColumnIndex;
                    firstRow = ParseRowRef(refStrPart1);
                    lastRow  = ParseRowRef(refStrPart2);
                }
                break;

            case NameType.Cell:
                CellReference cr;
                cr       = new CellReference(refStrPart1);
                firstRow = cr.Row;
                firstCol = cr.Col;
                cr       = new CellReference(refStrPart2);
                lastRow  = cr.Row;
                lastCol  = cr.Col;
                break;

            default:
                throw new InvalidOperationException("Unexpected reference classification of '" + refStrPart1 + "'.");
            }
            return(new LazyAreaEval(firstRow, firstCol, lastRow, lastCol, sre));
        }
Пример #14
0
        /**
         * Resolves a cell or area reference dynamically.
         * @param workbookName the name of the workbook Containing the reference.  If <code>null</code>
         * the current workbook is assumed.  Note - to Evaluate formulas which use multiple workbooks,
         * a {@link CollaboratingWorkbooksEnvironment} must be set up.
         * @param sheetName the name of the sheet Containing the reference.  May be <code>null</code>
         * (when <c>workbookName</c> is also null) in which case the current workbook and sheet is
         * assumed.
         * @param refStrPart1 the single cell reference or first part of the area reference.  Must not
         * be <code>null</code>.
         * @param refStrPart2 the second part of the area reference. For single cell references this
         * parameter must be <code>null</code>
         * @param isA1Style specifies the format for <c>refStrPart1</c> and <c>refStrPart2</c>.
         * Pass <c>true</c> for 'A1' style and <c>false</c> for 'R1C1' style.
         * TODO - currently POI only supports 'A1' reference style
         * @return a {@link RefEval} or {@link AreaEval}
         */
        public ValueEval GetDynamicReference(String workbookName, String sheetName, String refStrPart1,
                String refStrPart2, bool isA1Style)
        {
            if (!isA1Style)
            {
                throw new Exception("R1C1 style not supported yet");
            }
            SheetRefEvaluator se = CreateExternSheetRefEvaluator(workbookName, sheetName);
            if (se == null)
            {
                return ErrorEval.REF_INVALID;
            }
            SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);

            // ugly typecast - TODO - make spReadsheet version more easily accessible
            SpreadsheetVersion ssVersion = ((IFormulaParsingWorkbook)_workbook).GetSpreadsheetVersion();

            NameType part1refType = ClassifyCellReference(refStrPart1, ssVersion);
            switch (part1refType)
            {
                case NameType.BadCellOrNamedRange:
                    return ErrorEval.REF_INVALID;
                case NameType.NamedRange:
                    IEvaluationName nm = ((IFormulaParsingWorkbook)_workbook).GetName(refStrPart1, _sheetIndex);
                    if (!nm.IsRange)
                    {
                        throw new Exception("Specified name '" + refStrPart1 + "' is not a range as expected.");
                    }
                    return _bookEvaluator.EvaluateNameFormula(nm.NameDefinition, this);
            }
            if (refStrPart2 == null)
            {
                // no ':'
                switch (part1refType)
                {
                    case NameType.Column:
                    case NameType.Row:
                        return ErrorEval.REF_INVALID;
                    case NameType.Cell:
                        CellReference cr = new CellReference(refStrPart1);
                        return new LazyRefEval(cr.Row, cr.Col, sre);
                }
                throw new InvalidOperationException("Unexpected reference classification of '" + refStrPart1 + "'.");
            }
            NameType part2refType = ClassifyCellReference(refStrPart1, ssVersion);
            switch (part2refType)
            {
                case NameType.BadCellOrNamedRange:
                    return ErrorEval.REF_INVALID;
                case NameType.NamedRange:
                    throw new Exception("Cannot Evaluate '" + refStrPart1
                            + "'. Indirect Evaluation of defined names not supported yet");
            }

            if (part2refType != part1refType)
            {
                // LHS and RHS of ':' must be compatible
                return ErrorEval.REF_INVALID;
            }
            int firstRow, firstCol, lastRow, lastCol;
            switch (part1refType)
            {
                case NameType.Column:
                    firstRow = 0;
                    if (part2refType.Equals(NameType.Column))
                    {
                        lastRow = ssVersion.LastRowIndex;
                        firstCol = ParseRowRef(refStrPart1);
                        lastCol = ParseRowRef(refStrPart2);
                    }
                    else
                    {
                        lastRow = ssVersion.LastRowIndex;
                        firstCol = ParseColRef(refStrPart1);
                        lastCol = ParseColRef(refStrPart2);
                    }
                    break;
                case NameType.Row:
                    // support of cell range in the form of integer:integer
                    firstCol = 0;
                    if (part2refType.Equals(NameType.Row))
                    {
                        firstRow = ParseColRef(refStrPart1);
                        lastRow = ParseColRef(refStrPart2);
                        lastCol = ssVersion.LastColumnIndex;
                    }
                    else
                    {
                        lastCol = ssVersion.LastColumnIndex;
                        firstRow = ParseRowRef(refStrPart1);
                        lastRow = ParseRowRef(refStrPart2);
                    }
                    break;
                case NameType.Cell:
                    CellReference cr;
                    cr = new CellReference(refStrPart1);
                    firstRow = cr.Row;
                    firstCol = cr.Col;
                    cr = new CellReference(refStrPart2);
                    lastRow = cr.Row;
                    lastCol = cr.Col;
                    break;
                default:
                    throw new InvalidOperationException("Unexpected reference classification of '" + refStrPart1 + "'.");
            }
            return new LazyAreaEval(firstRow, firstCol, lastRow, lastCol, sre);
        }