const char* not being interpretted correctly

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 coing on?
Last edited on
Was an error returned by the method?
There are no compiler errors.

After running the code, just the cell (4,0) in excel file displays
YYYYYYYYY instead of the company name.
In case anyone else faces similar problem, this was solved using the suggestion on this link.
Topic archived. No new replies allowed.