I am trying to use libXl to output text from a C++ program to an Excel file.
The problem is coming with this library function:
bool writeStr(int row, int col, const wchar_t* value, Format* format = 0)
Writes a string into cell with specified format. If format equals 0 then format is ignored. String is copied internally and can be destroyed after call this method. Returns false if error occurs. Get error info with Book::errorMessage().
If I give input as a string literal like "Hello World" it is displayed correctly. However, if I try to give input as a variable of type const char*, it displays garbage.
Following is my code. MyCompany::company
is a QString
.
const char* companyName = MyCompany::company.toStdString().c_str();
sheet->writeStr(4, 0, companyName, companyFormat);
Can anybody tell me what's going on? How can I display a variable string using this library?
Thanks for your help.