pub struct IndexFn;Trait Implementations§
Source§impl Function for IndexFn
Returns the value or reference at a 1-based row and column within an array or range.
impl Function for IndexFn
Returns the value or reference at a 1-based row and column within an array or range.
INDEX can operate on both references and array literals. When the first argument is
a reference, this implementation resolves a referenced cell and materializes its value in
value context.
§Remarks
- Indexing is 1-based for both
row_numandcolumn_num. - If
column_numis omitted for a 1D array,row_numselects the position in that vector. row_num <= 0,column_num <= 0, or out-of-bounds indexes return#REF!.- Non-numeric index arguments return
#VALUE!.
§Examples
title: "Pick a value from a 2D table"
grid:
A1: "Item"
B1: "Price"
A2: "Pen"
B2: 2.5
A3: "Book"
B3: 8
formula: '=INDEX(A1:B3,3,2)'
expected: 8title: "Index into a 1D vector"
grid:
A1: "Q1"
A2: "Q2"
A3: "Q3"
formula: '=INDEX(A1:A3,2)'
expected: "Q2"related:
- MATCH
- XLOOKUP
- OFFSET
faq:
- q: "How does INDEX behave when column_num is omitted?"
a: "For 1D arrays, row_num selects the position along that vector; for 2D arrays, omitted column_num defaults to the first column."
- q: "Which errors indicate bad indexes?"
a: "Non-numeric index arguments return #VALUE!, while 0/negative or out-of-bounds indexes return #REF!."[formualizer-docgen:schema:start] Name: INDEX Type: IndexFn Min args: 2 Max args: 3 Variadic: false Signature: INDEX(arg1: any@range, arg2: number@scalar, arg3?: number@scalar) Arg schema: arg1{kinds=any,required=true,shape=range,by_ref=false,coercion=None,max=None,repeating=None,default=false}; arg2{kinds=number,required=true,shape=scalar,by_ref=false,coercion=NumberStrict,max=None,repeating=None,default=false}; arg3{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberStrict,max=None,repeating=None,default=false} Caps: PURE, RETURNS_REFERENCE [formualizer-docgen:schema:end]
fn name(&self) -> &'static str
fn min_args(&self) -> usize
fn arg_schema(&self) -> &'static [ArgSchema]
Source§fn eval_reference<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Option<Result<ReferenceType, ExcelError>>
Source§fn eval<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn eval<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
fn namespace(&self) -> &'static str
fn variadic(&self) -> bool
fn volatile(&self) -> bool
Source§fn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
fn function_salt(&self) -> u64
Source§fn dispatch<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn dispatch<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
Auto Trait Implementations§
impl Freeze for IndexFn
impl RefUnwindSafe for IndexFn
impl Send for IndexFn
impl Sync for IndexFn
impl Unpin for IndexFn
impl UnsafeUnpin for IndexFn
impl UnwindSafe for IndexFn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more