Return a string value to Excel.
static const char* RetString( const char* psz ); static const char* RetString( const std::string& s ); static const char* RetString( const CString& str ); |
The string to be returned.
A reference to the string to be returned.
A reference to the string to be returned.
A pointer to a string buffer that can be returned directly to Excel. The XLL+ run-time library will manage clean-up as required.
For a string to be returned to Excel, it is necessary that its lifetime extend beyond that of the function from which it is called. One solution is to return a pointer to static storage, but this can be unwieldy and wasteful.
An easier technique is to return a string using RetString(), e.g.:
return CXllApp::RetString("Not a number");
Since this function is static, it is not necessary to use an instance of CXllApp to invoke it. You can use code such as:
CString strResult; strResult.Format("%s%s", apszItemName[i], (j > 1) ? "s" : ""); return CXllApp::RetString(strResult);
Note: |
---|
This method is deprecated. |
Header: xllplus.h