#include #include #include #include #include #include namespace fs = std::filesystem; int main(int argc, char* argv[]) { if (argc < 2) { std::cout << "Second arg is xlsx file path." << std::endl; return 0; } std::string input_file(argv[1]); std::string full_path = ofen::COfPath::to_full(input_file); std::cout << "Load File:" << full_path << std::endl; if (!fs::exists(full_path)) { std::cerr << "File not found." << std::endl; return -1; } std::string file_name = fs::path(full_path).filename().string(); std::string out_file_name = ofen::COfStr::get_ofile_name(file_name); try { xlnt::workbook wb; wb.load(full_path); xlnt::workbook wb_out; xlnt::worksheet ws_out = wb_out.active_sheet(); std::cout << "Sheets in the workbook:" << std::endl; for (const auto& sheet_name : wb.sheet_titles()) { std::cout << " - " << sheet_name << std::endl; } std::string sheet_name = wb.sheet_titles().front(); xlnt::worksheet ws = wb.sheet_by_title(sheet_name); auto rows = ws.highest_row(); auto columns = ws.highest_column().index; std::cout << "Sheet: " << sheet_name << " has " << rows << " rows and " << columns << " columns." << std::endl; for (std::uint32_t i = 0; i < rows; ++i) { for (std::uint32_t j = 0; j < columns; ++j) { auto cell = ws.cell(j + 1, i + 1); if (cell.has_value()) { std::string cur = cell.to_string(); auto ret = ofen::CCodec::rbs(cur); ws_out.cell(j + 1, i + 1).value(ret); } } } wb_out.save(out_file_name); } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } std::cout << "Done" << std::endl; return 0; }