/// <summary> /// Read file as an XLSX-formatted ZIP file in the filesystem to a workbook, /// write the workbook back to memory, then ensure that the contents of the two files are equivalent. /// </summary> bool round_trip_matches_rw(const xlnt::path &original) { std::ifstream file_stream(original.string(), std::ios::binary); std::vector<std::uint8_t> original_data; { xlnt::detail::vector_ostreambuf file_data_buffer(original_data); std::ostream file_data_stream(&file_data_buffer); file_data_stream << file_stream.rdbuf(); } xlnt::workbook original_workbook; original_workbook.load(original); std::vector<std::uint8_t> buffer; original_workbook.save(buffer); original_workbook.save("round_trip_out.xlsx"); return xml_helper::xlsx_archives_match(original_data, buffer); }
void streaming_workbook_writer::open(const xlnt::path &filename) { stream_.reset(new std::ofstream()); xlnt::detail::open_stream(static_cast<std::ofstream &>(*stream_), filename.string()); open(*stream_); }