Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <xlnt/xlnt.hpp>
- #include <windows.h>
- static std::string utf8_to_ansi(const std::string &utf8)
- {
- WCHAR unicode[1500];
- char ansi[1500];
- memset(unicode, 0, sizeof(unicode));
- memset(ansi, 0, sizeof(ansi));
- ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, unicode, sizeof(unicode));
- ::WideCharToMultiByte(CP_ACP, 0, unicode, -1, ansi, sizeof(ansi), NULL, NULL);
- return std::string(ansi);
- }
- int
- main()
- {
- xlnt::workbook wb;
- wb.load("d:/test.xlsx");
- auto ws = wb.active_sheet();
- std::cout << "Processing spread sheet" << std::endl;
- for (const auto& row : ws.rows(false)) {
- for (const auto& cell : row) {
- const auto utf8_encoded = cell.to_string();
- std::cout << utf8_to_ansi(utf8_encoded) << std::endl;
- }
- }
- std::cout << "Processing complete " << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment