From 22be565b9247c81e69272db56306e2832eb6456b Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Mon, 25 Jul 2016 11:36:40 +1000 Subject: [PATCH] Add new test to confirm read then write doesn't change worksheet order --- source/workbook/tests/test_write_workbook.hpp | 37 ++++++++++++++++++ tests/data/genuine/tab_order.xlsx | Bin 0 -> 11208 bytes 2 files changed, 37 insertions(+) create mode 100644 tests/data/genuine/tab_order.xlsx diff --git a/source/workbook/tests/test_write_workbook.hpp b/source/workbook/tests/test_write_workbook.hpp index 76c483cb..7c40f6b2 100644 --- a/source/workbook/tests/test_write_workbook.hpp +++ b/source/workbook/tests/test_write_workbook.hpp @@ -225,6 +225,43 @@ public: TS_ASSERT(xml_helper::compare_xml(expected, xml)); } + void test_write_worksheet_order() + { + auto path = path_helper::get_data_directory("/genuine/tab_order.xlsx"); + + // Load an original workbook produced by Excel + xlnt::workbook wb_src; + { + xlnt::excel_serializer serializer(wb_src); + serializer.load_workbook(path); + } + + // Save it to a new file, unmodified + temporary_file file; + { + xlnt::excel_serializer serializer(wb_src); + serializer.save_workbook(file.get_filename()); + TS_ASSERT(path_helper::file_exists(file.get_filename())); + } + + // Load it again + xlnt::workbook wb_dst; + { + xlnt::excel_serializer serializer(wb_dst); + serializer.load_workbook(file.get_filename()); + } + + // Make sure the number of worksheets is the same + auto count_src = std::distance(wb_src.begin(), wb_src.end()); + auto count_dst = std::distance(wb_dst.begin(), wb_dst.end()); + TS_ASSERT(count_src == count_dst); + + // Make sure the title of the first sheet matches + auto ws1title_src = wb_src[0].get_title(); + auto ws1title_dst = wb_dst[0].get_title(); + TS_ASSERT(ws1title_src.compare(ws1title_dst) == 0); + } + private: xlnt::workbook wb_; }; diff --git a/tests/data/genuine/tab_order.xlsx b/tests/data/genuine/tab_order.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..f84e1b2a57d78833b7f89b0a1887154045ca156b GIT binary patch literal 11208 zcmeHtWn3J4vi9Ka5CQ~uAKV>+OK=J9!QI^@xCIY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