I'm tring to write Cyrillic characters into a spreadsheet that's being generated in an OSX app:
sheet = xlBookAddSheet(book, "Output", 0);
detailFormat = xlBookAddFormat(book, 0);
wchar_t *w_user = (wchar_t*)malloc(max_chars * sizeof(wchar_t));
//get wchar_t characters...
xlSheetWriteStr(sheet, row, column, w_user, detailFormat);
but the last line won't compile as the xlSheetWriteStr
is expecting const char*
in place of w_user.
According to the docs I should be able to pass in const wchar_t*
. Is there any way of writing my international characters to a cell?
LibXL provides headers for the
ANSI
andUNICODE
versions of the functions.Programs willing to use the unicode version of an API should define the
UNICODE
macro. If you are using Visual Studio it is as easy as going toProject -> Properties -> Character Set
and set it toUse Unicode Character Set
.What you see as
xlSheetWriteStr
is actually a macro that ends up having the valuexlSheetWriteStrA
orxlSheetWriteStrW
. IfUNICODE
is not defined the former, if it is de later.The function
xlSheetWriteStrA
is declared inSheetA.h
, whereasxlSheetWriteStrW
is declared inSheetW.h
.Note: It is better if you are consistent. If you use the unicode version of a function, use the unicode version of all functions. I say this because in your example I see you are using the ansi version of
xlBookAddSheet
.Update: For the OSX version of the library the macro is
_UNICODE
, with the preceding underscore (See libxl.h for details).