in black and white
Main menu
Share a book About us Home
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

Excel add in development in C++ Aplications in finance - Dalton S.

Dalton S. Excel add in development in C++ Aplications in finance - Wiley publishing , 2005. - 425 p.
ISBN 0-470-02469-0
Download (direct link): exceladdindevelopmentincand2005.pdf
Previous << 1 .. 96 97 98 99 100 101 < 102 > 103 104 105 106 107 108 .. 168 >> Next

Enumeration value: 107 (x6b)
Callable from: Commands only.
Return type: Text or an error value.
Arguments: 1: Name: A string satisfying the rules in section 8.10. (See table
below for examples.)
2: Returnedlnfo: A number specifying the type of information to return about the name. If 1 or omitted, returns the name’s definition (see following table for details). If 2, returns a Boolean which is true if the scope of the name is limited to the current sheet.
Suppose that three ranges have been defined but with the same name, TestName, in three places as shown in Table 8.20. Suppose also that Bookl is an open workbook containing Sheetl, Sheet2 and Sheet3.
Table 8.20 Example range definitions
Full name Where defined Definition
TestName DLL (see xlfSetName) [Bookl ,xls]Sheet3!R1C1:R2C2
[Bookl ,xls]Sheet1 ITestName Bookl. Sheetl [Bookl ,xls]Sheet1 !R2C2:R3C3
[Bookl ,xls]Sheet2!TestName Bookl. Sheet2 [Bookl ,xls]Sheet2!R3C3:R4C4
Table 8.21 summarises the values returned by xlfGetName in various contexts when the second argument is omitted. (See section 2.2, A1 versus R1C1 cell references on page 9 for an explanation of the R1C1 address style.)
Table 8.21 Example xlfGetName return values
Name passed as... The active sheet: The current sheet: Value returned
TestName Any. Any. =[Bookl ,xls]Sheet3!R1C1 :R2C2 The definition supplied in the call to xlfSetName. This may be a constant value or array, or a worksheet range as in this example.
(continued overleaf )
Excel Add-in Development in C/C++
Table 8.21 (continued)
Name passed as... The active sheet: The current sheet: Value returned
!TestName Sheetl Any. =R2C2:R3C3
!TestName Sheet2 Any. =R3C3:R4C4
!TestName Sheet3 Any. =Sheet1!R2C2:R3C3 Name on Sheet2 is masked by name on Sheetl.
!TestName Any sheet in any other workbook. Any. #NAME?
Sheetl!TestName Sheetl Any. =R2C2:R3C3
Sheetl!TestName Sheet2 Any. =[Bookl ,xls]Sheet1 !R2C2:R3C3
Sheetl!TestName Sheet3 Any. =[Bookl ,xls]Sheet1 !R2C2:R3C3
Sheetl!TestName Any sheet in any other workbook. Any sheet in any other workbook. #NAME?
Sheetl!TestName Any sheet in any other workbook. Bookl: Sheetl. Sheet2 or Sheet3 =[Book1 ,xls]Sheet1 !R2C2:R3C3
[Bookl.xls]Sheetl!TestName Sheetl Any. =R2C2:R3C3
[Bookl.xls]Sheetl!TestName Any other sheet in any workbook. Any. =[Book1 ,xls]Sheet1 !R2C2:R3C3
As you can see from the above table, the behaviour of this function, whilst being logical in its own interesting way, is a little confusing. Consequently, it’s best to use the most explicit form of the name, as shown at the bottom of the table, to avoid ambiguity or the need to check which is the active sheet before interpreting the result. Where the name is defined within the DLL, its definition is only accessible as shown at the top of Table 8.21. If the name is a worksheet name it must be prefixed with at least the ‘! ’.
Where a DLL name was defined as a constant value, even where this is a number, the function returns a string in which the value is prefixed with ‘=’. For example, if the value 1 was assigned, it returns “=1” and if the value “xyz” was assigned it returns ="xyx".
Accessing Excel Functionality Using the C API
The Excel4() function set-up and call are as shown in the following C/C++ code example of an exportable function that wraps up the call to xlfGetName.
xloper * stdcall GetName(char *name, xloper *p_info_type)
cpp_xloper Arg1(name); cpp_xloper RetVal;
int retval = Excel4(xlfGetName, &RetVal, 1, &Arg1, p_info_type); return RetVal.ExtractXloper(true);
If the name is defined as a reference to one or more cells, (the most common reason for defining a name), then to convert the text definition returned by xlfGetName you need to use xlfTextRef, after stripping the leading ‘=’ from the text address. (See section 8.9.15 Converting text to a reference: xlfTextref on page 235, and also the xlName class code listed on the CD ROM and discussed below.)
8.10.7 Getting the defined name of a range of cells: xlfGetDef
Enumeration value: Callable from: Return type: Arguments:
Returns the defined name of a range of cells (or other nameable object) given the corresponding range as text (or object ID). If no name corresponds to the reference provided, it returns #NAME?.
145 (x91)
Commands and macro sheet functions.
Text or an error value.
1: DefinitionText: A text representation of anything that a name can be assigned to. If a range of cells, then the range address must be expressed in R1C1 form.
2: DocumentText: The name of the sheet in the current workbook containing the object or range specified in DefinitionText. If omitted the sheet is assumed to be the DLL, i.e., the function returns the internal name if it exists. 3: TypeNum: A number indicating the type of name to find. 1 or omitted will only search for names that are not hidden, 2 only for names that are hidden and 3 for all names.
Where the range name is defined on a worksheet, the first argument should be passed as in the following code fragment, which places the name, if it exists, or #NAME? in RetVal:
Previous << 1 .. 96 97 98 99 100 101 < 102 > 103 104 105 106 107 108 .. 168 >> Next