XLL+ Class Library (7.0)

CXllApp::RetString

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
);

Parameters

psz

The string to be returned.

s

A reference to the string to be returned.

str

A reference to the string to be returned.

Return Value

A pointer to a string buffer that can be returned directly to Excel. The XLL+ run-time library will manage clean-up as required.

Remarks

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);

NoteNote:

This method is deprecated.

Requirements

Header: xllplus.h

See Also

CXllApp Class | CXllApp Methods