Một điểm liên quan là nó không phải là cần thiết để kiểm tra cả hai là một con trỏ đến một xl_array và địa chỉ của phần tử dữ liệu đầu tiên cả hai hợp lệ hoặc không phải là NULL. Nếu con trỏ để xl_array là đúng, thì địa chỉ của phần tử đầu tiên, | 152 Excel Add-in Development in C C p_op- xltype xltypeRef p_op- p p_op- idSheet p_op- count 1 xlref ref p- reftbl 0 to simplify code rwFirst rwLast colFirst colLast return true Converting an array of doubles strings or any other data type to an xltypeRef or an xltypeSRef is never a necessary thing to do. If you need to return an array of doubles integers or strings mixed or all one type to Excel via the return value of your DLL function you should use the xltypeMulti xloper. If you want to set the value of a particular cell that is not the calling cell then you can use the xlSet function although this can only be called from a command not from a worksheet function. The cpp_xloper class constructor for the xltypeSRef is cpp_xloper cpp_xloper WORD BYTE colLast rwFirst WORD rwLast BYTE colFirst Clear set_to_ xltypeSRef m_Op rwFirst rwLast colFirst colLast The two cpp_xloper class constructors for the xltypeRef are as follows. The first creates a reference on a named sheet. The second creates a reference on a sheet that is specified using its internal sheet ID. cpp_xloper cpp_xloper char sheet_name WORD rwFirst WORD rwLast Byte colFirst BYTE colLast Clear Check the inputs. No need to check sheet_name as creation of cpp_xloper will set type to xltypeMissing if sheet_name is not a valid name. if rwFirst rwLast colFirst colLast return Get the sheetID corresponding to the sheet_name provided. If sheet_name is missing a reference on the active sheet is created. cpp_xloper Name sheet_name cpp_xloper RetOper int xl4 Excel4 xlSheetId RetOper 1 Name DWORD ID if xl4 xlretSuccess set_to_xltypeRef m_Op ID rwFirst rwLast colFirst colLast Passing Data between Excel and the DLL 153 created successfully m_DLLtoFree true return Here is the code for the second constructor. It is much simpler than the above as the constructor does not .