本文整理汇总了C#中AreaEval.GetRelativeValue方法的典型用法代码示例。如果您正苦于以下问题:C# AreaEval.GetRelativeValue方法的具体用法?C# AreaEval.GetRelativeValue怎么用?C# AreaEval.GetRelativeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AreaEval
的用法示例。
在下文中一共展示了AreaEval.GetRelativeValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CountMatchingCellsInArea
/**
* @return the number of evaluated cells in the range that match the specified criteria
*/
public static int CountMatchingCellsInArea(AreaEval areaEval, I_MatchPredicate criteriaPredicate)
{
int result = 0;
int height = areaEval.Height;
int width = areaEval.Width;
for (int rrIx = 0; rrIx < height; rrIx++)
{
for (int rcIx = 0; rcIx < width; rcIx++)
{
ValueEval ve = areaEval.GetRelativeValue(rrIx, rcIx);
if (criteriaPredicate.Matches(ve))
{
result++;
}
}
}
return result;
}
示例2: ChooseSingleElementFromAreaInternal
/**
* @return possibly <tt>ErrorEval</tt>, and <c>null</c>
*/
private static ValueEval ChooseSingleElementFromAreaInternal(AreaEval ae,
int srcCellRow, short srcCellCol)
{
//if (false)
//{
// // this Is too simplistic
// if (ae.ContainsRow(srcCellRow) && ae.ContainsColumn(srcCellCol))
// {
// throw new EvaluationException(ErrorEval.CIRCULAR_REF_ERROR);
// }
// /*
// Circular references are not dealt with directly here, but it Is worth noting some Issues.
// ANY one of the return statements in this method could return a cell that Is identical
// to the one immediately being Evaluated. The evaluating cell Is identified by srcCellRow,
// srcCellRow AND sheet. The sheet Is not available in any nearby calling method, so that's
// one reason why circular references are not easy to detect here. (The sheet of the returned
// cell can be obtained from ae if it Is an Area3DEval.)
// Another reason there's little value in attempting to detect circular references here Is
// that only direct circular references could be detected. If the cycle involved two or more
// cells this method could not detect it.
// Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector
// (and HSSFFormulaEvaluator).
// */
//}
if (ae.IsColumn)
{
if (ae.IsRow)
{
return ae.GetRelativeValue(0, 0);
}
if (!ae.ContainsRow(srcCellRow))
{
throw EvaluationException.InvalidValue();
}
return ae.GetValueAt(srcCellRow, ae.FirstColumn);
}
if (!ae.IsRow)
{
// multi-column, multi-row area
if (ae.ContainsRow(srcCellRow) && ae.ContainsColumn(srcCellCol))
{
return ae.GetValueAt(ae.FirstRow, ae.FirstColumn);
}
throw EvaluationException.InvalidValue();
}
if (!ae.ContainsColumn(srcCellCol))
{
throw EvaluationException.InvalidValue();
}
return ae.GetValueAt(ae.FirstRow, srcCellCol);
}
示例3: GetValueFromArea
//.........这里部分代码省略.........
* <code>true</code>. ThIs parameter is needed because error codes are slightly
* different when only 2 args are passed.
*/
private static ValueEval GetValueFromArea(AreaEval ae, int pRowIx, int pColumnIx,
bool colArgWasPassed, int srcRowIx, int srcColIx)
{
bool rowArgWasEmpty = pRowIx == 0;
bool colArgWasEmpty = pColumnIx == 0;
int rowIx;
int columnIx;
// when the area ref Is a single row or a single column,
// there are special rules for conversion of rowIx and columnIx
if (ae.IsRow)
{
if (ae.IsColumn)
{
// single cell ref
rowIx = rowArgWasEmpty ? 0 : pRowIx - 1;
columnIx = colArgWasEmpty ? 0 : pColumnIx - 1;
}
else
{
if (colArgWasPassed)
{
rowIx = rowArgWasEmpty ? 0 : pRowIx - 1;
columnIx = pColumnIx - 1;
}
else
{
// special case - row arg seems to Get used as the column index
rowIx = 0;
// transfer both the index value and the empty flag from 'row' to 'column':
columnIx = pRowIx - 1;
colArgWasEmpty = rowArgWasEmpty;
}
}
}
else if (ae.IsColumn)
{
if (rowArgWasEmpty)
{
rowIx = srcRowIx - ae.FirstRow;
}
else
{
rowIx = pRowIx - 1;
}
if (colArgWasEmpty)
{
columnIx = 0;
}
else
{
columnIx = colArgWasEmpty ? 0 : pColumnIx - 1;
}
}
else
{
// ae Is an area (not single row or column)
if (!colArgWasPassed)
{
// always an error with 2-D area refs
// Note - the type of error Changes if the pRowArg is negative
throw new EvaluationException(pRowIx < 0 ? ErrorEval.VALUE_INVALID : ErrorEval.REF_INVALID);
}
// Normal case - area ref Is 2-D, and both index args were provided
// if either arg Is missing (or blank) the logic is similar to OperandResolver.getSingleValue()
if (rowArgWasEmpty)
{
rowIx = srcRowIx - ae.FirstRow;
}
else
{
rowIx = pRowIx - 1;
}
if (colArgWasEmpty)
{
columnIx = srcColIx - ae.FirstColumn;
}
else
{
columnIx = pColumnIx - 1;
}
}
int width = ae.Width;
int height = ae.Height;
// Slightly irregular logic for bounds checking errors
if (!rowArgWasEmpty && rowIx >= height || !colArgWasEmpty && columnIx >= width)
{
// high bounds check fail gives #REF! if arg was explicitly passed
throw new EvaluationException(ErrorEval.REF_INVALID);
}
if (rowIx < 0 || columnIx < 0 || rowIx >= height || columnIx >= width)
{
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
return ae.GetRelativeValue(rowIx, columnIx);
}
示例4: ThrowFirstError
private static void ThrowFirstError(AreaEval areaEval)
{
int height = areaEval.Height;
int width = areaEval.Width;
for (int rrIx = 0; rrIx < height; rrIx++)
{
for (int rcIx = 0; rcIx < width; rcIx++)
{
ValueEval ve = areaEval.GetRelativeValue(rrIx, rcIx);
if (ve is ErrorEval)
{
throw new EvaluationException((ErrorEval)ve);
}
}
}
}
示例5: GetValue
private static Double GetValue(AreaEval aeRange, int relRowIndex, int relColIndex)
{
ValueEval addend = aeRange.GetRelativeValue(relRowIndex, relColIndex);
if (addend is NumberEval)
{
return ((NumberEval)addend).NumberValue;
}
// everything else (including string and boolean values) counts as zero
return Double.NaN;
}
示例6: Accumulate
private static double Accumulate(AreaEval aeRange, I_MatchPredicate mp, AreaEval aeSum, int relRowIndex,
int relColIndex)
{
if (!mp.Matches(aeRange.GetRelativeValue(relRowIndex, relColIndex)))
{
return 0.0;
}
ValueEval addend = aeSum.GetRelativeValue(relRowIndex, relColIndex);
if (addend is NumberEval)
{
return ((NumberEval)addend).NumberValue;
}
// everything else (including string and boolean values) counts as zero
return 0.0;
}