Retrieve a binary name from a worksheet
[C++]
static BOOL GetBinaryName(
const char* pszName,
CXlBinaryNameData& data
);
static BOOL GetBinaryName(
const char* pszWorkbook,
const char* pszWorksheet,
const char* pszName,
CXlBinaryNameData& data
);
The name of the invisible range in the worksheet. The name must conform to Excel range name rules.
A reference to a data holder which will be set to point to the binary data associated with the name, if the function is successful.
Name of target workbook.
Name of target sheet.
The function returns TRUE if the name is found and the data is successfully retrieved,
or FALSE if the name does not exist or contains no data.
The data is retrieved into a CXlBinaryNameData
object in order to be sure that it is locked and unlocked properly.
Excel stores BinaryName data in Windows global moveable memory blocks,
and the CXlBinaryNameData object ensures that the GlobalFree() method is called when
the data holder goes out of scope. You should use the CXlBinaryNameData accessor methods to access the
data block: CXlBinaryNameData::GetCount
and CXlBinaryNameData::GetData.
Binary names are invisible Excel named ranges, accessible only to the
add-in programmer, not to the user.
They differ from visible ranges in that you cannot us them for Excel data types,
only for buffers of binary data. Binary names are held in worksheets, and are unique at worksheet level.
However, there may be multiple instances of a binary name in a workbook
(as many as there are worksheets in the book). The first form of the function acts on the active sheet of the active workbook. The second form acts on the requested sheet. In order to do so, the active workbook
and sheet are changed if required, and then changed back again after the
action is complete.
BinaryName data can be added to the active worksheet and retrieved
using code like the following:// Set data
double adValues[2] = { 1.0, 2.0 };
BOOL ok = CXllApp::DefineBinaryName("value_pair", (void*)adValues, sizeof(adValues));
// Retrieve data
CXlBinaryNameData data;
ok = CXllApp::GetBinaryName("value_pair", data);
if (ok && data.GetCount() == sizeof(adValues))
{
memcpy(adValues, data.GetData(), sizeof(adValues));
}
Header: xllplus.h
CXllApp Class
| CXllApp Methods
| CXllApp::DefineBinaryName()
| CXllApp::ClearBinaryName()
| CXlBinaryNameData object