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

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 .. 87 88 89 90 91 92 < 93 > 94 95 96 97 98 99 .. 168 >> Next

13 The number of windows that the sheet is displayed with.
14 The calculation mode: 1 = Automatic 2 = Automatic except tables 3 = Manual
15, 18, 19, 20 Options dialog box, Calculation tab checkbox settings as either true or false: 15: Returns the Iteration checkbox state 18: Returns the Update Remote References checkbox state 19: Returns the Precision As Displayed checkbox state 20: Returns the 1904 Date System checkbox state
16 Maximum number of iterations.
17 Maximum change between iterations.
33 The state of the Recalculate Before Saving checkbox in the Calculation tab of the Options dialog box.
34 True if the workbook is read-only recommended.
35 True if the workbook is write-reserved.
36 If the workbook has a write-reservation password and it is opened with read/write permission, returns the name of the user who originally saved it with the write-reservation password. If the workbook is opened as read-only, or if a password has not been added, returns the name of the current user.
48 The standard column width setting.
(continued overleaf)
220
Excel Add-in Development in C/C++
Table 8.14 (continued)
68 The workbook name without path.
76 The name of the active sheet in the form [Bookl ,xls]Sheet1
84 The value of the first circular reference on the sheet, or #N/A if none.
87 The position of the given sheet in the workbook. If the workbook name is not given with the sheet name, operates on the current workbook. (Includes hidden sheets and counts from 1.)
88 The workbook name in the form Bookl
The Excel4() function set-up and call would be as shown in the following C/C++ code example of an exportable function that wraps up the call to xlfGetDocument and returns whatever is returned from that call.
xloper * stdcall get_document(int arg_num, char *sheet_name)
{
xloper argl, arg2; static xloper ret_xloper;
if(arg_num < 1 || arg_num > 88) return p_xlErrValue;
argl.xltype = xltypeInt; argl.val.w = arg_num;
if(sheet_name)
{
arg2.xltype = xltypeStr;
arg2.val.str = new_xlstring(sheet_name);
}
else
arg2.xltype = xltypeMissing;
Excel4(xlfGetDocument, &ret_xloper, 2, &arg1, &arg2);
// Tell Excel to free up memory that it might have allocated for // the return value.
ret_xloper.xltype |= xlbitXLFree;
if(sheet_name)
free(arg2.val.str);
return &ret_xloper;
}
Using the cpp_xloper class, the equivalent code becomes:
xloper * stdcall get_document(int arg_num, char *sheet_name)
{
cpp_xloper Arg1(arg_num, 1, 88);
Accessing Excel Functionality Using the C API
221
if(!Arg1.IsType(xltypeInt)) return p_xlErrValue;
cpp_xloper Arg2(sheet_name); cpp_xloper RetVal;
Excel4(xlfGetDocument, &RetVal, 2, &Arg1, &Arg2); return RetVal.ExtractXloper(true);
}
8.9.7 Getting the formula of a cell: xlfGetFormula
Overview: Returns the formula, as text, of the top left cell in a given reference. The formula is returned in R1C1 style (see section 2.2, A1 versus R1C1 cell references for details).
Enumeration value: 106 (x6a)
Callable from: Commands and macro sheet functions.
Return type: Text or error.
Arguments: Ref. A reference xloper.
The Excel4() function set-up and call would be as shown in the following C/C++ code example of an exportable function that wraps up the call to xlfGetFormula. The function returns the formula as a string.
xloper * stdcall get formula(xloper *p ref) { cpp xloper RetVal; Excel4(xlfGetFormula, &RetVal, 1, p ref); // Extract and return the xloper, using Excel to free memory return RetVal.ExtractXloper(true); }
8.9.8 Getting a cell’s comment: xlfGetNote
Overview: Returns the text of the comment attached to the top left cell in
the given reference. If no comment has been added to the cell, it returns an empty string.
Enumeration value: 191 (xbf)
Callable from: Commands and macro sheet functions.
Return type: Text.
Arguments:
Ref. A reference xloper.
222
Excel Add-in Development in C/C++
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 xlfGetNote. The arguments passed in are a row and column numbers that count from 0. The function creates a reference to a single cell on the current sheet and returns the comment as a string.
xloper * stdcall get_note(long row, long column)
{
xloper Arg;
static xloper ret_xloper;
// Create a simple single-cell reference to cell on current sheet Arg.xltype = xltypeSRef;
Arg.val.sref.count = 1;
// First row in sheet = row 0 Arg.val.sref.ref.rwFirst =
Arg.val.sref.ref.rwLast = (WORD)row;
// First column in sheet = column 0 Arg.val.sref.ref.colFirst =
Arg.val.sref.ref.colLast = (BYTE)column;
int retval = Excel4(xlfGetNote, &ret_xloper, 1, &Arg);
// Tell Excel to free up memory that it might have allocated for // the return value.
ret_xloper.xltype | = xlbitXLFree; return &ret_xloper;
}
The following code is equivalent to the above, but uses the cpp_xloper class.
xloper * stdcall get_note(long row, long column)
{
// Create a simple single-cell reference to cell on current sheet cpp_xloper Arg((WORD)row, (WORD)row, (BYTE)column, (BYTE)column); cpp_xloper RetVal;
Previous << 1 .. 87 88 89 90 91 92 < 93 > 94 95 96 97 98 99 .. 168 >> Next