I found some code on the web a while back. But I don't know who wrote it.
The code below looks for worksheet names in a excel file. I am not familiar with C++ (and do little to nothing with binary files). Can someone help me convert the code below from C++ to VB.net? Thank you in advance.
trf
IStorage *pStorage = 0;
HRESULT hResult = ::StgOpenStorage(L"C:\\MyExcel.xls", NULL, STGM_READ |STGM_SHARE_DENY_WRITE, NULL, 0, &pStorage);
IStream *pStream = 0;
hResult = pStorage->OpenStream(L"Workbook", NULL, STGM_READ |STGM_SHARE_EXCLUSIVE, 0, &pStream);
char buf[32000]; DWORD dwRead = 0; short id = 0, len = 0;
while (1) {
hResult = pStream->Read(&id, 2, &dwRead);
if( (FAILED(hResult)) || (dwRead != 2) ) break;
hResult = pStream->Read(&len, 2, &dwRead);
if( (FAILED(hResult)) || dwRead != 2 || ((id == 0) && (len == 0)) ) break;
if( (id & 0x00FF) == 0x85 ) {
pStream->Read(buf, len, &dwRead);
buf[len] = 0;
cout << buf+8 << endl;
continue;
}
if(len > sizeof(buf)) len = sizeof(buf);
pStream->Read(buf, (long)len, &dwRead);
if((DWORD)len != dwRead) break;
}