// Copyright (c) 2014-2016 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE // // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file #pragma once #include #include #include #include #include #include #include namespace xlnt { class workbook; /// /// Handles reading and writing workbooks from an actual XLSX archive /// using other serializers. /// class XLNT_CLASS excel_serializer { public: /// /// /// static const std::string central_directory_signature(); /// /// /// static std::string repair_central_directory(const std::string &original); /// /// Construct an excel_serializer which operates on wb. /// excel_serializer(workbook &wb); /// /// Create a ZIP file in memory, load archive from filename, then populate workbook /// with data from archive. /// bool load_workbook(const std::string &filename, bool guess_types = false, bool data_only = false); /// /// Create a ZIP file in memory, load archive from stream, then populate workbook /// with data from archive. /// bool load_stream_workbook(std::istream &stream, bool guess_types = false, bool data_only = false); /// /// Create a ZIP file in memory, load archive from bytes, then populate workbook /// with data from archive. /// bool load_virtual_workbook( const std::vector &bytes, bool guess_types = false, bool data_only = false); /// /// Create a ZIP file in memory, save workbook to this archive, then save archive /// to filename. /// bool save_workbook(const std::string &filename, bool as_template = false); /// /// Create a ZIP file in memory, save workbook to this archive, then assign ZIP file /// binary data to bytes. /// bool save_virtual_workbook(std::vector &bytes, bool as_template = false); /// /// Create a ZIP file in memory, save workbook to this archive, then copy ZIP file /// binary data to stream. /// bool save_stream_workbook(std::ostream &stream, bool as_template = false); xlnt::detail::stylesheet &get_stylesheet(); private: /// /// Reads all files in archive and populates workbook with associated data /// using other appropriate serializers such as workbook_serializer. /// void read_data(bool guess_types, bool data_only); /// /// Read xl/sharedStrings.xml from internal archive and add shared strings to workbook. /// void read_shared_strings(); /// /// /// void read_images(); /// /// /// void read_charts(); /// /// /// void read_chartsheets(); /// /// /// void read_worksheets(); /// /// /// void read_external_links(); /// /// Write all files needed to create a valid XLSX file which represents all /// data contained in workbook. /// void write_data(bool as_template); /// /// Write xl/sharedStrings.xml to internal archive based on shared strings in workbook. /// void write_shared_strings(); /// /// /// void write_images(); /// /// /// void write_charts(); /// /// /// void write_chartsheets(); /// /// /// void write_worksheets(); /// /// /// void write_external_links(); /// /// A reference to the workbook which is the object of read/write operations. /// workbook &workbook_; /// /// The internal archive which holds files representing workbook_ during /// read/write operations. /// zip_file archive_; }; } // namespace xlnt