1. 现象:
Compiling... ExcelText.cpp D:/MyWork/ginfo/client/src/skexcel/ExcelText.cpp(240) : error C2440: 'return' : cannot convert from 'class WTL::CString' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:/MyWork/ginfo/client/src/skexcel/ExcelText.cpp(243) : error C2440: 'return' : cannot convert from 'unsigned short [1]' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe.
2. 代码:
2.1 错误代码:
LPCSTR CExcelText::ReadCell(DWORD dwRow, DWORD dwColumn) { if (m_lpCurSheetInfo != NULL) { LPEXCELCELLINFO lpCellInfo = LookupCell(dwRow, dwColumn); if (lpCellInfo != NULL) { return lpCellInfo->strText; } } return _T(""); }
3. 解决方法:
将粗体部分改为:
return (LPCSTR)(LPCTSTR)_T("");
return (LPCSTR)(LPCTSTR)lpCellInfo->strText;

