UTF-8 in XMLWriter
C++ library for creating XLSX files for MS Excel 2007 and above.
Brought to you by:
oxod,
programmeralex
Hello to everyone!
To quickly add UTF-8 support in XmlStream Class (inside XmlWriter.h) I overload << operator for _tstring:
And add following function:
Now three provided test works with UTF (at least Russian text displayed as typed)
Yes, it quick and dirty, but it works ;)
WideCharToMultiByte might not work because i use unicode, std::wofstream << std::string is the problem.
Instead, i figure it out using boost.
if you have built "boost filesystem",
then you only have to modify xmlwriter.h:
add
and, line 38
s.imbue(std::locale("C"));
modify it to
done.
however, if you have not built boost filesystem and you won't plan to,
then steps are more complicated as below.
.............................................................................
insert code below to xmlwriter.h, line 8
xmlwriter.h, line 38, delete or comment it, as
// s.imbue(std::locale("C"));
and insert code below
insert code below to Workbook.cpp, line 54
....................................................................................................
done, try it with
SimpleXlsx::CWorkbook book;
SimpleXlsx::CWorksheet &sheet = book.AddSheet(L"檊");
SimpleXlsx::CellDataStr cds;
cds.value = L"檊";
sheet.BeginRow();
sheet.AddCell(cds);
sheet.EndRow();
It works.
Remarks:
SimpleXlsx version 0.20
Visual Studio 2010 Express, Win32, unicode, boost_1_58_0
Last edit: FinnG 2016-02-15