12.07.2015 Views

Excel Add-in Development in C/C++: Applications in ... - F9

Excel Add-in Development in C/C++: Applications in ... - F9

Excel Add-in Development in C/C++: Applications in ... - F9

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14 <strong>Excel</strong> <strong>Add</strong>-<strong>in</strong> <strong>Development</strong> <strong>in</strong> C/<strong>C++</strong>Table 2.4 Case-<strong>in</strong>sensitive str<strong>in</strong>g comparisonsFormula...="A"="a"="a">"Z"="Z">"["=CHAR(90)>CHAR(91)...evaluates to:TRUEFALSETRUETRUEApart from str<strong>in</strong>g case conversion, <strong>Excel</strong> does not convert operands for these operators.Table 2.5 shows some examples of the consequences:Table 2.5 Mixed-type comparisonsFormula......evaluates to:=123="123" FALSE=123>"121" FALSE=123"123" TRUE=TRUE ="TRUE"FALSE2.6.7 Conversion of s<strong>in</strong>gle-cell references<strong>Excel</strong> will convert a s<strong>in</strong>gle-cell reference to the value of the cell referred to, unless it isbe<strong>in</strong>g passed to a function that expects a reference as its parameter rather than a value.(Later chapters go <strong>in</strong>to detail on such functions, but a simple example is ROW(), whichextracts and returns the row number of a cell reference.) If an operator or function us<strong>in</strong>gthe reference requires a different data type than that of the reference’s value, then <strong>Excel</strong>will also attempt to convert to the required type. (See next section for more detail.) Forexample, if a cell conta<strong>in</strong>s the formula =SUM(A1,B1), with A1 conta<strong>in</strong><strong>in</strong>g the number 123and B2 the str<strong>in</strong>g "456", <strong>Excel</strong> will convert the reference A1 to the value of that cell, 123,and the reference B1 to the str<strong>in</strong>g "456" and then to the argument type expected by SUM(),the number 456, lead<strong>in</strong>g f<strong>in</strong>ally to a result of 579.2.6.8 Conversion of multi-cell range referencesSome functions will work equally well with s<strong>in</strong>gle cell references and range references,for example, SUM(A1,B1,C1) gives the same result as SUM(A1:C1). In the latter case, theSUM() function converts the range A1:C1 to a mixed type array of values and then iteratesthrough that convert<strong>in</strong>g and summ<strong>in</strong>g values where possible. The work of handl<strong>in</strong>g therange argument is done with<strong>in</strong> the code of the SUM() function.However, there are cases where <strong>Excel</strong> needs to convert a range argument before call<strong>in</strong>ga function or apply<strong>in</strong>g an operator. Here the behaviour is a little more complex. Table 2.6shows how <strong>Excel</strong> copes with range arguments <strong>in</strong> comb<strong>in</strong>ation with a simple arithmeticoperation, plus one <strong>in</strong> this case. (The str<strong>in</strong>gs <strong>in</strong> row 3 <strong>in</strong>dicate the formulae entered <strong>in</strong> the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!