2017-01-03 09:35:18 +08:00
|
|
|
// Copyright (c) 2014-2017 Thomas Fussell
|
2015-12-25 04:51:11 +08:00
|
|
|
// 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
|
2016-11-08 10:55:40 +08:00
|
|
|
|
2014-05-22 05:48:51 +08:00
|
|
|
#include <algorithm>
|
2014-06-11 05:12:15 +08:00
|
|
|
#include <array>
|
2014-06-05 06:42:17 +08:00
|
|
|
#include <fstream>
|
2016-06-11 01:40:50 +08:00
|
|
|
#include <functional>
|
2014-07-27 04:19:15 +08:00
|
|
|
#include <set>
|
2014-05-21 22:20:30 +08:00
|
|
|
|
2017-04-21 02:03:03 +08:00
|
|
|
#include <detail/constants.hpp>
|
|
|
|
#include <detail/default_case.hpp>
|
|
|
|
#include <detail/implementations/cell_impl.hpp>
|
|
|
|
#include <detail/implementations/workbook_impl.hpp>
|
|
|
|
#include <detail/implementations/worksheet_impl.hpp>
|
|
|
|
#include <detail/serialization/excel_thumbnail.hpp>
|
|
|
|
#include <detail/serialization/vector_streambuf.hpp>
|
|
|
|
#include <detail/serialization/xlsx_consumer.hpp>
|
|
|
|
#include <detail/serialization/xlsx_producer.hpp>
|
2016-08-16 12:23:49 +08:00
|
|
|
#include <xlnt/cell/cell.hpp>
|
2015-11-03 22:06:01 +08:00
|
|
|
#include <xlnt/packaging/manifest.hpp>
|
2015-11-03 21:38:09 +08:00
|
|
|
#include <xlnt/packaging/relationship.hpp>
|
2015-10-19 03:30:46 +08:00
|
|
|
#include <xlnt/styles/alignment.hpp>
|
2015-10-21 11:30:10 +08:00
|
|
|
#include <xlnt/styles/border.hpp>
|
2015-10-19 03:30:46 +08:00
|
|
|
#include <xlnt/styles/fill.hpp>
|
|
|
|
#include <xlnt/styles/font.hpp>
|
2016-12-24 23:04:57 +08:00
|
|
|
#include <xlnt/styles/format.hpp>
|
2015-10-19 03:30:46 +08:00
|
|
|
#include <xlnt/styles/number_format.hpp>
|
|
|
|
#include <xlnt/styles/protection.hpp>
|
2016-12-24 23:04:57 +08:00
|
|
|
#include <xlnt/styles/style.hpp>
|
2015-11-03 21:38:09 +08:00
|
|
|
#include <xlnt/utils/exceptions.hpp>
|
2016-08-03 12:12:18 +08:00
|
|
|
#include <xlnt/utils/path.hpp>
|
2017-01-16 08:08:57 +08:00
|
|
|
#include <xlnt/utils/variant.hpp>
|
|
|
|
#include <xlnt/workbook/metadata_property.hpp>
|
2015-10-15 06:05:13 +08:00
|
|
|
#include <xlnt/workbook/named_range.hpp>
|
2015-10-30 07:37:07 +08:00
|
|
|
#include <xlnt/workbook/theme.hpp>
|
2015-10-14 12:03:48 +08:00
|
|
|
#include <xlnt/workbook/workbook.hpp>
|
2016-08-14 02:45:26 +08:00
|
|
|
#include <xlnt/workbook/workbook_view.hpp>
|
2016-01-25 00:15:49 +08:00
|
|
|
#include <xlnt/workbook/worksheet_iterator.hpp>
|
2016-12-10 08:18:50 +08:00
|
|
|
#include <xlnt/worksheet/header_footer.hpp>
|
2015-10-14 12:03:48 +08:00
|
|
|
#include <xlnt/worksheet/range.hpp>
|
|
|
|
#include <xlnt/worksheet/worksheet.hpp>
|
2014-08-14 06:56:34 +08:00
|
|
|
|
2016-11-08 10:11:30 +08:00
|
|
|
namespace {
|
|
|
|
|
2016-11-20 08:41:21 +08:00
|
|
|
#ifdef _MSC_VER
|
2016-11-08 10:11:30 +08:00
|
|
|
void open_stream(std::ifstream &stream, const std::wstring &path)
|
|
|
|
{
|
|
|
|
stream.open(path, std::ios::binary);
|
|
|
|
}
|
|
|
|
|
|
|
|
void open_stream(std::ofstream &stream, const std::wstring &path)
|
|
|
|
{
|
|
|
|
stream.open(path, std::ios::binary);
|
|
|
|
}
|
|
|
|
|
|
|
|
void open_stream(std::ifstream &stream, const std::string &path)
|
|
|
|
{
|
2017-04-13 22:58:40 +08:00
|
|
|
open_stream(stream, xlnt::path(path).wstring());
|
2016-11-08 10:11:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void open_stream(std::ofstream &stream, const std::string &path)
|
|
|
|
{
|
2017-04-13 22:58:40 +08:00
|
|
|
open_stream(stream, xlnt::path(path).wstring());
|
2016-11-08 10:11:30 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
void open_stream(std::ifstream &stream, const std::string &path)
|
|
|
|
{
|
|
|
|
stream.open(path, std::ios::binary);
|
|
|
|
}
|
|
|
|
|
|
|
|
void open_stream(std::ofstream &stream, const std::string &path)
|
|
|
|
{
|
|
|
|
stream.open(path, std::ios::binary);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-15 03:09:01 +08:00
|
|
|
template<typename T>
|
2017-02-18 13:11:06 +08:00
|
|
|
std::vector<T> keys(const std::vector<std::pair<T, xlnt::variant>> &container)
|
2017-01-15 03:09:01 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
auto result = std::vector<T>();
|
2017-01-15 03:09:01 +08:00
|
|
|
auto iter = container.begin();
|
|
|
|
|
|
|
|
while (iter != container.end())
|
|
|
|
{
|
|
|
|
result.push_back((iter++)->first);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-02-18 13:11:06 +08:00
|
|
|
template<typename T>
|
|
|
|
bool contains(const std::vector<std::pair<T, xlnt::variant>> &container, const T key)
|
|
|
|
{
|
|
|
|
for (const auto &iter : container)
|
|
|
|
{
|
|
|
|
if (iter.first == key)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-21 22:04:10 +08:00
|
|
|
xlnt::path default_path(xlnt::relationship_type type, std::size_t index = 0)
|
|
|
|
{
|
|
|
|
using xlnt::path;
|
|
|
|
using xlnt::relationship_type;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case relationship_type::calculation_chain:
|
|
|
|
return path("/xl/calcChain.xml");
|
|
|
|
case relationship_type::chartsheet:
|
|
|
|
return path("/xl/sheets/.xml");
|
|
|
|
case relationship_type::comments:
|
|
|
|
return path("/xl/comments.xml");
|
|
|
|
case relationship_type::connections:
|
|
|
|
return path("/xl/connections.xml");
|
|
|
|
case relationship_type::core_properties:
|
|
|
|
return path("/docProps/core.xml");
|
|
|
|
case relationship_type::custom_properties:
|
|
|
|
return path("/docProps/custom.xml");
|
|
|
|
case relationship_type::custom_property:
|
|
|
|
return path("/xl/customProperty.xml");
|
|
|
|
case relationship_type::custom_xml_mappings:
|
|
|
|
return path("/xl/customXmlMappings.xml");
|
|
|
|
case relationship_type::dialogsheet:
|
|
|
|
return path("/xl/dialogsheets/sheet.xml");
|
|
|
|
case relationship_type::drawings:
|
|
|
|
return path("/xl/drawings/drawing.xml");
|
|
|
|
case relationship_type::extended_properties:
|
|
|
|
return path("/docProps/app.xml");
|
|
|
|
case relationship_type::external_workbook_references:
|
|
|
|
return path("/xl/external.xml");
|
|
|
|
case relationship_type::hyperlink:
|
|
|
|
return path("/xl/hyperlink.xml");
|
|
|
|
case relationship_type::image:
|
|
|
|
return path("?");
|
|
|
|
case relationship_type::office_document:
|
|
|
|
return path("/xl/workbook.xml");
|
|
|
|
case relationship_type::pivot_table:
|
|
|
|
return path("/xl/pivotTable.xml");
|
|
|
|
case relationship_type::pivot_table_cache_definition:
|
|
|
|
return path("?");
|
|
|
|
case relationship_type::pivot_table_cache_records:
|
|
|
|
return path("?");
|
|
|
|
case relationship_type::printer_settings:
|
|
|
|
return path("/xl/printerSettings.xml");
|
|
|
|
case relationship_type::query_table:
|
|
|
|
return path("/xl/queryTable.xml");
|
|
|
|
case relationship_type::revision_log:
|
|
|
|
return path("/xl/revisionLog.xml");
|
|
|
|
case relationship_type::shared_string_table:
|
|
|
|
return path("/xl/sharedStrings.xml");
|
|
|
|
case relationship_type::shared_workbook:
|
|
|
|
return path("/xl/sharedWorkbook.xml");
|
|
|
|
case relationship_type::shared_workbook_revision_headers:
|
|
|
|
return path("?");
|
|
|
|
case relationship_type::shared_workbook_user_data:
|
|
|
|
return path("?");
|
|
|
|
case relationship_type::single_cell_table_definitions:
|
|
|
|
return path("?");
|
|
|
|
case relationship_type::stylesheet:
|
|
|
|
return path("/xl/styles.xml");
|
|
|
|
case relationship_type::table_definition:
|
|
|
|
return path("/xl/tableDefinition.xml");
|
|
|
|
case relationship_type::theme:
|
|
|
|
return path("/xl/theme/theme1.xml");
|
|
|
|
case relationship_type::thumbnail:
|
|
|
|
return path("/docProps/thumbnail.jpg");
|
|
|
|
case relationship_type::unknown:
|
|
|
|
return path("/xl/unknown.xml");
|
|
|
|
case relationship_type::vml_drawing:
|
|
|
|
return path("/xl/vmlDrawing.xml");
|
|
|
|
case relationship_type::volatile_dependencies:
|
|
|
|
return path("/xl/volatileDependencies.xml");
|
|
|
|
case relationship_type::worksheet:
|
|
|
|
return path("/xl/worksheets/sheet" + std::to_string(index) + ".xml");
|
|
|
|
}
|
|
|
|
|
|
|
|
default_case(path("/xl/unknownPart.xml"));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string content_type(xlnt::relationship_type type)
|
|
|
|
{
|
|
|
|
using xlnt::relationship_type;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case relationship_type::calculation_chain:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml";
|
|
|
|
case relationship_type::chartsheet:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml";
|
|
|
|
case relationship_type::comments:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
|
|
|
|
case relationship_type::connections:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml";
|
|
|
|
case relationship_type::core_properties:
|
|
|
|
return "application/vnd.openxmlformats-package.core-properties+xml";
|
|
|
|
case relationship_type::custom_properties:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.custom-properties+xml";
|
|
|
|
case relationship_type::custom_property:
|
2017-03-21 07:22:46 +08:00
|
|
|
throw xlnt::unhandled_switch_case();
|
2017-01-21 22:04:10 +08:00
|
|
|
case relationship_type::custom_xml_mappings:
|
|
|
|
return "application/xml";
|
|
|
|
case relationship_type::dialogsheet:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml";
|
|
|
|
case relationship_type::drawings:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.drawing+xml";
|
|
|
|
case relationship_type::extended_properties:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
|
|
|
case relationship_type::external_workbook_references:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml";
|
|
|
|
case relationship_type::hyperlink:
|
2017-03-21 07:22:46 +08:00
|
|
|
throw xlnt::unhandled_switch_case();
|
2017-01-21 22:04:10 +08:00
|
|
|
case relationship_type::image:
|
2017-03-21 07:22:46 +08:00
|
|
|
throw xlnt::unhandled_switch_case();
|
2017-01-21 22:04:10 +08:00
|
|
|
case relationship_type::office_document:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
|
|
|
case relationship_type::pivot_table:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
|
|
|
|
case relationship_type::pivot_table_cache_definition:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
|
|
|
|
case relationship_type::pivot_table_cache_records:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
|
|
|
|
case relationship_type::printer_settings:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings";
|
|
|
|
case relationship_type::query_table:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml";
|
|
|
|
case relationship_type::revision_log:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml";
|
|
|
|
case relationship_type::shared_string_table:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
|
|
|
|
case relationship_type::shared_workbook:
|
2017-03-21 07:22:46 +08:00
|
|
|
throw xlnt::unhandled_switch_case();
|
2017-01-21 22:04:10 +08:00
|
|
|
case relationship_type::shared_workbook_revision_headers:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml";
|
|
|
|
case relationship_type::shared_workbook_user_data:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml";
|
|
|
|
case relationship_type::single_cell_table_definitions:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml";
|
|
|
|
case relationship_type::stylesheet:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml";
|
|
|
|
case relationship_type::table_definition:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
|
|
|
|
case relationship_type::theme:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
|
|
case relationship_type::thumbnail:
|
|
|
|
return "image/jpeg";
|
|
|
|
case relationship_type::unknown:
|
|
|
|
return "";
|
|
|
|
case relationship_type::vml_drawing:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.vmlDrawing";
|
|
|
|
case relationship_type::volatile_dependencies:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml";
|
|
|
|
case relationship_type::worksheet:
|
|
|
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
|
|
|
}
|
|
|
|
|
|
|
|
default_case("application/xml");
|
|
|
|
}
|
|
|
|
|
2016-11-08 10:11:30 +08:00
|
|
|
} // namespace
|
|
|
|
|
2014-05-21 22:20:30 +08:00
|
|
|
namespace xlnt {
|
2014-07-25 05:31:46 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
bool workbook::has_core_property(xlnt::core_property type) const
|
2016-12-02 21:37:50 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
return ::contains(d_->core_properties_, type);
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
std::vector<xlnt::core_property> workbook::core_properties() const
|
2017-01-15 03:09:01 +08:00
|
|
|
{
|
|
|
|
return keys(d_->core_properties_);
|
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
variant workbook::core_property(xlnt::core_property type) const
|
2016-12-26 22:38:26 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
for (auto iter : d_->core_properties_)
|
|
|
|
{
|
|
|
|
if (iter.first == type)
|
|
|
|
{
|
|
|
|
return iter.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw xlnt::exception("workbook doesn't have core property");
|
2016-12-26 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
void workbook::core_property(xlnt::core_property type, const variant &value)
|
2016-12-02 21:37:50 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
register_package_part(relationship_type::core_properties);
|
2017-02-18 13:11:06 +08:00
|
|
|
|
|
|
|
for (auto &iter : d_->core_properties_)
|
|
|
|
{
|
|
|
|
if (iter.first == type)
|
|
|
|
{
|
|
|
|
iter.second = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d_->core_properties_.push_back({type, value});
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
bool workbook::has_extended_property(xlnt::extended_property type) const
|
2016-12-02 21:37:50 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
return ::contains(d_->extended_properties_, type);
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
std::vector<xlnt::extended_property> workbook::extended_properties() const
|
2017-01-15 03:09:01 +08:00
|
|
|
{
|
|
|
|
return keys(d_->extended_properties_);
|
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
void workbook::extended_property(xlnt::extended_property type, const variant &value)
|
2016-12-26 22:38:26 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
register_package_part(relationship_type::extended_properties);
|
2017-02-18 13:11:06 +08:00
|
|
|
|
|
|
|
for (auto &iter : d_->extended_properties_)
|
|
|
|
{
|
|
|
|
if (iter.first == type)
|
|
|
|
{
|
|
|
|
iter.second = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d_->extended_properties_.push_back({type, value});
|
2016-12-26 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
variant workbook::extended_property(xlnt::extended_property type) const
|
2016-12-26 22:38:26 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
for (auto iter : d_->extended_properties_)
|
|
|
|
{
|
|
|
|
if (iter.first == type)
|
|
|
|
{
|
|
|
|
return iter.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw xlnt::exception("workbook doesn't have extended property");
|
2016-12-26 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2017-01-03 06:42:16 +08:00
|
|
|
bool workbook::has_custom_property(const std::string &property_name) const
|
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
return ::contains(d_->custom_properties_, property_name);
|
2017-01-03 06:42:16 +08:00
|
|
|
}
|
|
|
|
|
2017-01-15 03:09:01 +08:00
|
|
|
std::vector<std::string> workbook::custom_properties() const
|
|
|
|
{
|
|
|
|
return keys(d_->custom_properties_);
|
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
void workbook::custom_property(const std::string &property_name, const variant &value)
|
2017-01-03 06:42:16 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
register_package_part(relationship_type::custom_properties);
|
2017-02-18 13:11:06 +08:00
|
|
|
|
|
|
|
for (auto &iter : d_->custom_properties_)
|
|
|
|
{
|
|
|
|
if (iter.first == property_name)
|
|
|
|
{
|
|
|
|
iter.second = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d_->custom_properties_.push_back({property_name, value});
|
2017-01-03 06:42:16 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
variant workbook::custom_property(const std::string &property_name) const
|
2017-01-03 06:42:16 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
for (auto iter : d_->custom_properties_)
|
|
|
|
{
|
|
|
|
if (iter.first == property_name)
|
|
|
|
{
|
|
|
|
return iter.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
throw xlnt::exception("workbook doesn't have custom property");
|
2017-01-03 06:42:16 +08:00
|
|
|
}
|
|
|
|
|
2016-12-30 07:36:29 +08:00
|
|
|
workbook workbook::empty()
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
auto impl = new detail::workbook_impl();
|
|
|
|
workbook wb(impl);
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
wb.register_package_part(relationship_type::office_document);
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2017-01-15 03:09:01 +08:00
|
|
|
wb.d_->manifest_.register_default_type("rels",
|
|
|
|
"application/vnd.openxmlformats-package.relationships+xml");
|
|
|
|
wb.d_->manifest_.register_default_type("xml",
|
|
|
|
"application/xml");
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
wb.thumbnail(excel_thumbnail(), "jpeg", "image/jpeg");
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
wb.core_property(xlnt::core_property::creator, "Microsoft Office User");
|
|
|
|
wb.core_property(xlnt::core_property::last_modified_by, "Microsoft Office User");
|
|
|
|
wb.core_property(xlnt::core_property::created, datetime(2016, 8, 12, 3, 16, 56));
|
|
|
|
wb.core_property(xlnt::core_property::modified, datetime(2016, 8, 12, 3, 17, 16));
|
|
|
|
|
|
|
|
wb.extended_property(xlnt::extended_property::application, "Microsoft Macintosh Excel");
|
|
|
|
wb.extended_property(xlnt::extended_property::doc_security, 0);
|
2017-02-18 13:11:06 +08:00
|
|
|
wb.extended_property(xlnt::extended_property::scale_crop, false);
|
|
|
|
wb.extended_property(xlnt::extended_property::heading_pairs, std::vector<variant>{variant("Worksheets"), variant(1)});
|
|
|
|
wb.extended_property(xlnt::extended_property::titles_of_parts, {"Sheet1"});
|
2017-01-16 08:08:57 +08:00
|
|
|
wb.extended_property(xlnt::extended_property::company, "");
|
|
|
|
wb.extended_property(xlnt::extended_property::links_up_to_date, false);
|
|
|
|
wb.extended_property(xlnt::extended_property::shared_doc, false);
|
|
|
|
wb.extended_property(xlnt::extended_property::hyperlinks_changed, false);
|
|
|
|
wb.extended_property(xlnt::extended_property::app_version, "15.0300");
|
2016-12-02 21:37:50 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
auto file_version = detail::workbook_impl::file_version_t{"xl", 6, 6, 26709};
|
|
|
|
wb.d_->file_version_ = file_version;
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2016-12-26 22:38:26 +08:00
|
|
|
xlnt::workbook_view wb_view;
|
|
|
|
wb_view.x_window = 0;
|
|
|
|
wb_view.y_window = 460;
|
|
|
|
wb_view.window_width = 28800;
|
|
|
|
wb_view.window_height = 17460;
|
|
|
|
wb_view.tab_ratio = 500;
|
|
|
|
wb.view(wb_view);
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
auto ws = wb.create_sheet();
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2016-09-06 10:17:36 +08:00
|
|
|
page_margins margins;
|
2016-12-02 21:37:50 +08:00
|
|
|
margins.left(0.7);
|
|
|
|
margins.right(0.7);
|
|
|
|
margins.top(0.75);
|
|
|
|
margins.bottom(0.75);
|
|
|
|
margins.header(0.3);
|
|
|
|
margins.footer(0.3);
|
2016-12-24 23:04:57 +08:00
|
|
|
ws.page_margins(margins);
|
2016-12-02 21:37:50 +08:00
|
|
|
|
|
|
|
sheet_view view;
|
|
|
|
ws.add_view(view);
|
|
|
|
|
2016-12-26 22:38:26 +08:00
|
|
|
wb.theme(xlnt::theme());
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
wb.d_->stylesheet_ = detail::stylesheet();
|
|
|
|
auto &stylesheet = wb.d_->stylesheet_.get();
|
2016-12-30 07:36:29 +08:00
|
|
|
stylesheet.parent = &wb;
|
2016-08-13 11:06:25 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
auto default_border = border()
|
2016-12-30 07:36:29 +08:00
|
|
|
.side(border_side::bottom, border::border_property())
|
|
|
|
.side(border_side::top, border::border_property())
|
|
|
|
.side(border_side::start, border::border_property())
|
|
|
|
.side(border_side::end, border::border_property())
|
|
|
|
.side(border_side::diagonal, border::border_property());
|
2016-12-24 23:04:57 +08:00
|
|
|
wb.d_->stylesheet_.get().borders.push_back(default_border);
|
2016-08-18 19:34:18 +08:00
|
|
|
|
2017-01-15 03:09:01 +08:00
|
|
|
auto default_fill = fill(pattern_fill()
|
|
|
|
.type(pattern_fill_type::none));
|
2016-12-24 23:04:57 +08:00
|
|
|
stylesheet.fills.push_back(default_fill);
|
2017-01-15 03:09:01 +08:00
|
|
|
auto gray125_fill = pattern_fill()
|
|
|
|
.type(pattern_fill_type::gray125);
|
2016-12-24 23:04:57 +08:00
|
|
|
stylesheet.fills.push_back(gray125_fill);
|
2016-08-18 19:34:18 +08:00
|
|
|
|
2017-01-15 03:09:01 +08:00
|
|
|
auto default_font = font()
|
|
|
|
.name("Calibri")
|
|
|
|
.size(12)
|
|
|
|
.scheme("minor")
|
|
|
|
.family(2)
|
|
|
|
.color(theme_color(1));
|
2016-12-24 23:04:57 +08:00
|
|
|
stylesheet.fonts.push_back(default_font);
|
2016-11-08 10:11:30 +08:00
|
|
|
|
2017-03-26 22:30:26 +08:00
|
|
|
wb.create_builtin_style(0);
|
2016-11-08 10:11:30 +08:00
|
|
|
|
2016-11-10 08:52:18 +08:00
|
|
|
wb.create_format(true)
|
2016-11-08 10:11:30 +08:00
|
|
|
.border(default_border, false)
|
|
|
|
.fill(default_fill, false)
|
|
|
|
.font(default_font, false)
|
|
|
|
.number_format(xlnt::number_format::general(), false)
|
|
|
|
.style("Normal");
|
2016-08-18 19:34:18 +08:00
|
|
|
|
2016-12-26 22:38:26 +08:00
|
|
|
xlnt::calculation_properties calc_props;
|
|
|
|
calc_props.calc_id = 150000;
|
|
|
|
calc_props.concurrent_calc = false;
|
|
|
|
wb.calculation_properties(calc_props);
|
2016-08-18 19:34:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return wb;
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
workbook::workbook()
|
|
|
|
{
|
2016-12-30 07:36:29 +08:00
|
|
|
auto wb_template = empty();
|
2017-03-21 08:17:09 +08:00
|
|
|
swap(wb_template);
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
workbook::workbook(detail::workbook_impl *impl)
|
|
|
|
: d_(impl)
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-11-04 07:26:11 +08:00
|
|
|
if (impl != nullptr)
|
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
if (d_->stylesheet_.is_set())
|
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
d_->stylesheet_.get().parent = this;
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
2016-11-04 07:26:11 +08:00
|
|
|
}
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
void workbook::register_package_part(relationship_type type)
|
2016-08-16 12:23:49 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
if (!manifest().has_relationship(path("/"), type))
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
manifest().register_override_type(default_path(type), content_type(type));
|
|
|
|
manifest().register_relationship(uri("/"), type,
|
2017-02-08 05:49:02 +08:00
|
|
|
uri(default_path(type).relative_to(path("/")).string()),
|
2017-01-16 08:08:57 +08:00
|
|
|
target_mode::internal);
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
2016-08-16 12:23:49 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
void workbook::register_workbook_part(relationship_type type)
|
2016-08-16 12:23:49 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
auto wb_rel = manifest().relationship(path("/"), relationship_type::office_document);
|
|
|
|
auto wb_path = manifest().canonicalize({ wb_rel });
|
2016-08-16 12:23:49 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
if (!manifest().has_relationship(wb_path, type))
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
manifest().register_override_type(default_path(type), content_type(type));
|
|
|
|
manifest().register_relationship(uri(wb_path.string()), type,
|
|
|
|
uri(default_path(type).relative_to(wb_path.resolve(path("/"))).string()),
|
|
|
|
target_mode::internal);
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
2016-08-16 12:23:49 +08:00
|
|
|
}
|
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
void workbook::register_worksheet_part(worksheet ws, relationship_type type)
|
2016-08-16 12:23:49 +08:00
|
|
|
{
|
2017-01-15 03:09:01 +08:00
|
|
|
auto wb_rel = manifest().relationship(path("/"),
|
|
|
|
relationship_type::office_document);
|
2017-01-16 08:08:57 +08:00
|
|
|
auto ws_rel = manifest().relationship(wb_rel.target().path(),
|
2017-01-15 03:09:01 +08:00
|
|
|
d_->sheet_title_rel_id_map_.at(ws.title()));
|
2016-12-24 23:04:57 +08:00
|
|
|
path ws_path(ws_rel.source().path().parent().append(ws_rel.target().path()));
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
if (type == relationship_type::comments)
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
if (!manifest().has_relationship(ws_path, relationship_type::vml_drawing))
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
std::size_t file_number = 1;
|
|
|
|
path filename("vmlDrawing1.vml");
|
|
|
|
bool filename_exists = true;
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
while (filename_exists)
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
filename_exists = false;
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
for (auto current_ws_rel :
|
|
|
|
manifest().relationships(wb_rel.target().path(), xlnt::relationship_type::worksheet))
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
path current_ws_path(current_ws_rel.source().path().parent().append(current_ws_rel.target().path()));
|
|
|
|
if (!manifest().has_relationship(current_ws_path, xlnt::relationship_type::vml_drawing)) continue;
|
|
|
|
|
|
|
|
for (auto current_ws_child_rel :
|
|
|
|
manifest().relationships(current_ws_path, xlnt::relationship_type::vml_drawing))
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
if (current_ws_child_rel.target().path() == path("../drawings").append(filename))
|
|
|
|
{
|
|
|
|
filename_exists = true;
|
|
|
|
break;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
|
|
|
}
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
if (filename_exists)
|
|
|
|
{
|
|
|
|
file_number++;
|
|
|
|
filename = path("vmlDrawing" + std::to_string(file_number) + ".vml");
|
|
|
|
}
|
2016-11-25 21:13:55 +08:00
|
|
|
}
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
manifest().register_default_type("vml", "application/vnd.openxmlformats-officedocument.vmlDrawing");
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
const path relative_path(path("../drawings").append(filename));
|
|
|
|
manifest().register_relationship(
|
|
|
|
uri(ws_path.string()), relationship_type::vml_drawing, uri(relative_path.string()), target_mode::internal);
|
|
|
|
}
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
if (!manifest().has_relationship(ws_path, relationship_type::comments))
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
std::size_t file_number = 1;
|
|
|
|
path filename("comments1.xml");
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
if (!manifest().has_override_type(constants::package_xl().append(filename))) break;
|
|
|
|
|
|
|
|
file_number++;
|
|
|
|
filename = path("comments" + std::to_string(file_number) + ".xml");
|
|
|
|
}
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
const path absolute_path(constants::package_xl().append(filename));
|
|
|
|
manifest().register_override_type(
|
|
|
|
absolute_path, "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml");
|
2016-10-30 04:31:30 +08:00
|
|
|
|
2017-01-16 08:08:57 +08:00
|
|
|
const path relative_path(path("..").append(filename));
|
|
|
|
manifest().register_relationship(
|
|
|
|
uri(ws_path.string()), relationship_type::comments, uri(relative_path.string()), target_mode::internal);
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
2016-10-30 04:31:30 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const worksheet workbook::sheet_by_title(const std::string &title) const
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
for (auto &impl : d_->worksheets_)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-08-05 13:52:05 +08:00
|
|
|
if (impl.title_ == title)
|
2014-06-13 05:04:37 +08:00
|
|
|
{
|
|
|
|
return worksheet(&impl);
|
|
|
|
}
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2014-05-30 08:52:14 +08:00
|
|
|
|
2016-07-30 06:55:49 +08:00
|
|
|
throw key_not_found();
|
2014-05-30 08:52:14 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
worksheet workbook::sheet_by_title(const std::string &title)
|
2016-05-26 10:05:30 +08:00
|
|
|
{
|
2016-07-22 11:04:36 +08:00
|
|
|
for (auto &impl : d_->worksheets_)
|
|
|
|
{
|
2016-08-05 13:52:05 +08:00
|
|
|
if (impl.title_ == title)
|
2016-07-22 11:04:36 +08:00
|
|
|
{
|
|
|
|
return worksheet(&impl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 06:55:49 +08:00
|
|
|
throw key_not_found();
|
2016-05-26 10:05:30 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
worksheet workbook::sheet_by_index(std::size_t index)
|
2014-05-30 08:52:14 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
if (index >= d_->worksheets_.size())
|
|
|
|
{
|
|
|
|
throw invalid_parameter();
|
|
|
|
}
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
auto iter = d_->worksheets_.begin();
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
for (std::size_t i = 0; i < index; ++i)
|
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
++iter;
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return worksheet(&*iter);
|
2014-05-30 08:52:14 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const worksheet workbook::sheet_by_index(std::size_t index) const
|
2014-05-30 08:52:14 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
auto iter = d_->worksheets_.begin();
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
for (std::size_t i = 0; i < index; ++i, ++iter)
|
|
|
|
{
|
|
|
|
}
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return worksheet(&*iter);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
worksheet workbook::sheet_by_id(std::size_t id)
|
2016-08-05 13:52:05 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
for (auto &impl : d_->worksheets_)
|
|
|
|
{
|
|
|
|
if (impl.id_ == id)
|
|
|
|
{
|
|
|
|
return worksheet(&impl);
|
|
|
|
}
|
|
|
|
}
|
2016-08-05 13:52:05 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
throw key_not_found();
|
2016-08-05 13:52:05 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const worksheet workbook::sheet_by_id(std::size_t id) const
|
2016-08-05 13:52:05 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
for (auto &impl : d_->worksheets_)
|
|
|
|
{
|
|
|
|
if (impl.id_ == id)
|
|
|
|
{
|
|
|
|
return worksheet(&impl);
|
|
|
|
}
|
|
|
|
}
|
2016-08-05 13:52:05 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
throw key_not_found();
|
2016-08-05 13:52:05 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
worksheet workbook::active_sheet()
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return sheet_by_index(d_->active_sheet_index_.is_set() ? d_->active_sheet_index_.get() : 0);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2015-11-11 07:58:54 +08:00
|
|
|
bool workbook::has_named_range(const std::string &name) const
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
for (auto worksheet : *this)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
if (worksheet.has_named_range(name))
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
worksheet workbook::create_sheet()
|
2015-11-01 22:43:01 +08:00
|
|
|
{
|
2016-08-13 11:06:25 +08:00
|
|
|
std::string title = "Sheet1";
|
|
|
|
int index = 1;
|
2014-05-30 08:52:14 +08:00
|
|
|
|
2016-07-22 11:04:36 +08:00
|
|
|
while (contains(title))
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-11 07:58:54 +08:00
|
|
|
title = "Sheet" + std::to_string(++index);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2014-06-10 12:29:49 +08:00
|
|
|
|
2016-07-27 08:13:09 +08:00
|
|
|
auto sheet_id = d_->worksheets_.size() + 1;
|
|
|
|
std::string sheet_filename = "sheet" + std::to_string(sheet_id) + ".xml";
|
|
|
|
|
|
|
|
d_->worksheets_.push_back(detail::worksheet_impl(this, sheet_id, title));
|
2016-08-05 13:52:05 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
auto workbook_rel = d_->manifest_.relationship(path("/"), relationship_type::office_document);
|
2016-09-06 10:17:36 +08:00
|
|
|
uri relative_sheet_uri(path("worksheets").append(sheet_filename).string());
|
2016-12-02 21:37:50 +08:00
|
|
|
auto absolute_sheet_path = path("/xl").append(relative_sheet_uri.path());
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->manifest_.register_override_type(
|
|
|
|
absolute_sheet_path, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
|
|
|
|
auto ws_rel = d_->manifest_.register_relationship(
|
|
|
|
workbook_rel.target(), relationship_type::worksheet, relative_sheet_uri, target_mode::internal);
|
|
|
|
d_->sheet_title_rel_id_map_[title] = ws_rel;
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2017-02-27 20:47:33 +08:00
|
|
|
update_sheet_properties();
|
|
|
|
|
2015-11-01 22:43:01 +08:00
|
|
|
return worksheet(&d_->worksheets_.back());
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2017-01-27 08:57:19 +08:00
|
|
|
worksheet workbook::copy_sheet(worksheet to_copy)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
if (to_copy.d_->parent_ != this) throw invalid_parameter();
|
2016-03-08 11:35:22 +08:00
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
detail::worksheet_impl impl(*to_copy.d_);
|
2016-07-18 02:59:11 +08:00
|
|
|
auto new_sheet = create_sheet();
|
2016-12-02 21:37:50 +08:00
|
|
|
impl.title_ = new_sheet.title();
|
2016-07-18 02:59:11 +08:00
|
|
|
*new_sheet.d_ = impl;
|
2017-02-08 05:49:02 +08:00
|
|
|
|
2017-01-27 08:57:19 +08:00
|
|
|
return new_sheet;
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2017-01-27 08:57:19 +08:00
|
|
|
worksheet workbook::copy_sheet(worksheet to_copy, std::size_t index)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-08-16 12:23:49 +08:00
|
|
|
copy_sheet(to_copy);
|
2016-07-22 10:14:00 +08:00
|
|
|
|
|
|
|
if (index != d_->worksheets_.size() - 1)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
auto iter = d_->worksheets_.begin();
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
for (std::size_t i = 0; i < index; ++i, ++iter)
|
|
|
|
{
|
|
|
|
}
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->worksheets_.insert(iter, d_->worksheets_.back());
|
|
|
|
d_->worksheets_.pop_back();
|
2016-07-22 10:14:00 +08:00
|
|
|
}
|
2017-02-08 05:49:02 +08:00
|
|
|
|
2017-01-27 08:57:19 +08:00
|
|
|
return sheet_by_index(index);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::size_t workbook::index(worksheet ws)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-08-16 12:23:49 +08:00
|
|
|
auto match = std::find(begin(), end(), ws);
|
2016-07-22 10:14:00 +08:00
|
|
|
|
|
|
|
if (match == end())
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
throw invalid_parameter();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2016-07-22 10:14:00 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
return static_cast<std::size_t>(std::distance(begin(), match));
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2015-11-11 08:47:31 +08:00
|
|
|
void workbook::create_named_range(const std::string &name, worksheet range_owner, const std::string &reference_string)
|
|
|
|
{
|
|
|
|
create_named_range(name, range_owner, range_reference(reference_string));
|
|
|
|
}
|
|
|
|
|
2015-11-11 07:58:54 +08:00
|
|
|
void workbook::create_named_range(const std::string &name, worksheet range_owner, const range_reference &reference)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
sheet_by_title(range_owner.title()).create_named_range(name, reference);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2015-11-11 07:58:54 +08:00
|
|
|
void workbook::remove_named_range(const std::string &name)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
for (auto ws : *this)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
if (ws.has_named_range(name))
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2014-05-30 08:52:14 +08:00
|
|
|
ws.remove_named_range(name);
|
2014-05-21 22:20:30 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
throw key_not_found();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
range workbook::named_range(const std::string &name)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
for (auto ws : *this)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
if (ws.has_named_range(name))
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
return ws.named_range(name);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
throw key_not_found();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-08-05 13:52:05 +08:00
|
|
|
void workbook::load(std::istream &stream)
|
2014-06-13 05:04:37 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
clear();
|
2016-08-05 13:52:05 +08:00
|
|
|
detail::xlsx_consumer consumer(*this);
|
2016-12-24 23:04:57 +08:00
|
|
|
consumer.read(stream);
|
2014-06-13 05:04:37 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-10-10 19:28:49 +08:00
|
|
|
void workbook::load(const std::vector<std::uint8_t> &data)
|
2014-06-05 06:42:17 +08:00
|
|
|
{
|
2016-12-10 08:18:50 +08:00
|
|
|
if (data.size() < 22) // the shortest ZIP file is 22 bytes
|
|
|
|
{
|
|
|
|
throw xlnt::exception("file is empty or malformed");
|
|
|
|
}
|
|
|
|
|
2016-10-31 03:48:40 +08:00
|
|
|
xlnt::detail::vector_istreambuf data_buffer(data);
|
|
|
|
std::istream data_stream(&data_buffer);
|
2016-10-31 09:17:51 +08:00
|
|
|
load(data_stream);
|
2014-06-05 06:42:17 +08:00
|
|
|
}
|
|
|
|
|
2016-08-05 13:52:05 +08:00
|
|
|
void workbook::load(const std::string &filename)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return load(path(filename));
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
2015-10-30 07:37:07 +08:00
|
|
|
|
2016-08-05 13:52:05 +08:00
|
|
|
void workbook::load(const path &filename)
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
std::ifstream file_stream;
|
2016-11-08 10:11:30 +08:00
|
|
|
open_stream(file_stream, filename.string());
|
2016-12-10 08:18:50 +08:00
|
|
|
|
|
|
|
if (!file_stream.good())
|
|
|
|
{
|
|
|
|
throw xlnt::exception("file not found " + filename.string());
|
|
|
|
}
|
|
|
|
|
2016-10-31 09:17:51 +08:00
|
|
|
load(file_stream);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2014-06-14 05:06:23 +08:00
|
|
|
|
2016-10-10 19:28:49 +08:00
|
|
|
void workbook::load(const std::string &filename, const std::string &password)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return load(path(filename), password);
|
2016-10-10 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::load(const path &filename, const std::string &password)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
std::ifstream file_stream;
|
2016-11-08 10:11:30 +08:00
|
|
|
open_stream(file_stream, filename.string());
|
2016-12-10 08:18:50 +08:00
|
|
|
|
|
|
|
if (!file_stream.good())
|
|
|
|
{
|
|
|
|
throw xlnt::exception("file not found " + filename.string());
|
|
|
|
}
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return load(file_stream, password);
|
2016-10-10 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::load(const std::vector<std::uint8_t> &data, const std::string &password)
|
|
|
|
{
|
2016-12-10 08:18:50 +08:00
|
|
|
if (data.size() < 22) // the shortest ZIP file is 22 bytes
|
|
|
|
{
|
|
|
|
throw xlnt::exception("file is empty or malformed");
|
|
|
|
}
|
|
|
|
|
2016-10-31 03:48:40 +08:00
|
|
|
xlnt::detail::vector_istreambuf data_buffer(data);
|
|
|
|
std::istream data_stream(&data_buffer);
|
2016-10-31 09:17:51 +08:00
|
|
|
load(data_stream, password);
|
2016-10-10 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::load(std::istream &stream, const std::string &password)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
clear();
|
|
|
|
detail::xlsx_consumer consumer(*this);
|
|
|
|
consumer.read(stream, password);
|
2016-10-10 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::save(std::vector<std::uint8_t> &data) const
|
2014-07-25 05:31:46 +08:00
|
|
|
{
|
2016-10-31 03:48:40 +08:00
|
|
|
xlnt::detail::vector_ostreambuf data_buffer(data);
|
|
|
|
std::ostream data_stream(&data_buffer);
|
|
|
|
save(data_stream);
|
2014-07-25 05:31:46 +08:00
|
|
|
}
|
|
|
|
|
2017-02-18 13:11:06 +08:00
|
|
|
void workbook::save(std::vector<std::uint8_t> &data, const std::string &password) const
|
|
|
|
{
|
|
|
|
xlnt::detail::vector_ostreambuf data_buffer(data);
|
|
|
|
std::ostream data_stream(&data_buffer);
|
|
|
|
save(data_stream, password);
|
|
|
|
}
|
|
|
|
|
2016-08-06 22:40:17 +08:00
|
|
|
void workbook::save(const std::string &filename) const
|
2014-07-25 05:31:46 +08:00
|
|
|
{
|
2017-02-18 13:11:06 +08:00
|
|
|
save(path(filename));
|
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::save(const std::string &filename, const std::string &password) const
|
|
|
|
{
|
|
|
|
save(path(filename), password);
|
2014-07-25 05:31:46 +08:00
|
|
|
}
|
|
|
|
|
2016-08-06 22:40:17 +08:00
|
|
|
void workbook::save(const path &filename) const
|
2014-06-14 05:06:23 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
std::ofstream file_stream;
|
2016-11-08 10:11:30 +08:00
|
|
|
open_stream(file_stream, filename.string());
|
2016-12-24 23:04:57 +08:00
|
|
|
save(file_stream);
|
2014-06-14 05:06:23 +08:00
|
|
|
}
|
|
|
|
|
2017-02-18 13:11:06 +08:00
|
|
|
void workbook::save(const path &filename, const std::string &password) const
|
|
|
|
{
|
|
|
|
std::ofstream file_stream;
|
|
|
|
open_stream(file_stream, filename.string());
|
|
|
|
save(file_stream, password);
|
|
|
|
}
|
|
|
|
|
2016-08-06 22:40:17 +08:00
|
|
|
void workbook::save(std::ostream &stream) const
|
2016-05-16 03:03:02 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
detail::xlsx_producer producer(*this);
|
|
|
|
producer.write(stream);
|
2016-05-16 03:03:02 +08:00
|
|
|
}
|
|
|
|
|
2017-02-18 13:11:06 +08:00
|
|
|
void workbook::save(std::ostream &stream, const std::string &password) const
|
2016-11-08 10:55:40 +08:00
|
|
|
{
|
|
|
|
detail::xlsx_producer producer(*this);
|
|
|
|
producer.write(stream, password);
|
|
|
|
}
|
|
|
|
|
2016-11-20 08:41:21 +08:00
|
|
|
#ifdef _MSC_VER
|
2017-02-18 13:11:06 +08:00
|
|
|
void workbook::save(const std::wstring &filename) const
|
2016-10-31 09:17:51 +08:00
|
|
|
{
|
2016-11-08 10:11:30 +08:00
|
|
|
std::ofstream file_stream;
|
|
|
|
open_stream(file_stream, filename);
|
2016-10-31 09:17:51 +08:00
|
|
|
save(file_stream);
|
|
|
|
}
|
|
|
|
|
2017-02-18 13:11:06 +08:00
|
|
|
void workbook::save(const std::wstring &filename, const std::string &password) const
|
2016-11-08 10:11:30 +08:00
|
|
|
{
|
|
|
|
std::ofstream file_stream;
|
|
|
|
open_stream(file_stream, filename);
|
|
|
|
save(file_stream, password);
|
|
|
|
}
|
|
|
|
|
2016-10-31 09:17:51 +08:00
|
|
|
void workbook::load(const std::wstring &filename)
|
|
|
|
{
|
2016-11-08 10:11:30 +08:00
|
|
|
std::ifstream file_stream;
|
|
|
|
open_stream(file_stream, filename);
|
|
|
|
load(file_stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::load(const std::wstring &filename, const std::string &password)
|
|
|
|
{
|
|
|
|
std::ifstream file_stream;
|
|
|
|
open_stream(file_stream, filename);
|
2016-11-08 10:55:40 +08:00
|
|
|
load(file_stream, password);
|
2016-10-31 09:17:51 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-21 22:20:30 +08:00
|
|
|
void workbook::remove_sheet(worksheet ws)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
auto match_iter = std::find_if(
|
|
|
|
d_->worksheets_.begin(), d_->worksheets_.end(), [=](detail::worksheet_impl &comp) { return &comp == ws.d_; });
|
2014-05-30 08:52:14 +08:00
|
|
|
|
2015-11-01 22:43:01 +08:00
|
|
|
if (match_iter == d_->worksheets_.end())
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
throw invalid_parameter();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
auto ws_rel_id = d_->sheet_title_rel_id_map_.at(ws.title());
|
2017-02-27 20:47:33 +08:00
|
|
|
auto wb_rel = d_->manifest_.relationship(path("/"), xlnt::relationship_type::office_document);
|
2016-12-24 23:04:57 +08:00
|
|
|
auto ws_rel = d_->manifest_.relationship(wb_rel.target().path(), ws_rel_id);
|
2017-02-27 20:47:33 +08:00
|
|
|
auto ws_part = d_->manifest_.canonicalize({wb_rel, ws_rel}).resolve(path("/"));
|
|
|
|
d_->manifest_.unregister_override_type(ws_part);
|
2017-01-09 03:12:55 +08:00
|
|
|
auto rel_id_map = d_->manifest_.unregister_relationship(wb_rel.target(), ws_rel_id);
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->sheet_title_rel_id_map_.erase(ws.title());
|
2014-05-30 08:52:14 +08:00
|
|
|
d_->worksheets_.erase(match_iter);
|
2017-01-09 03:12:55 +08:00
|
|
|
|
|
|
|
// Shift sheet title->ID mappings down as a result of manifest::unregister_relationship above.
|
|
|
|
for (auto &title_rel_id_pair : d_->sheet_title_rel_id_map_)
|
|
|
|
{
|
|
|
|
title_rel_id_pair.second = rel_id_map.count(title_rel_id_pair.second) > 0
|
|
|
|
? rel_id_map[title_rel_id_pair.second] : title_rel_id_pair.second;
|
|
|
|
}
|
2017-02-27 20:47:33 +08:00
|
|
|
|
|
|
|
update_sheet_properties();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
worksheet workbook::create_sheet(std::size_t index)
|
|
|
|
{
|
2014-05-30 08:52:14 +08:00
|
|
|
create_sheet();
|
2015-11-01 22:43:01 +08:00
|
|
|
|
|
|
|
if (index != d_->worksheets_.size() - 1)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
auto iter = d_->worksheets_.begin();
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
for (std::size_t i = 0; i < index; ++i, ++iter)
|
|
|
|
{
|
|
|
|
}
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->worksheets_.insert(iter, d_->worksheets_.back());
|
|
|
|
d_->worksheets_.pop_back();
|
2015-11-01 22:43:01 +08:00
|
|
|
}
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return sheet_by_index(index);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-08-02 06:33:43 +08:00
|
|
|
worksheet workbook::create_sheet_with_rel(const std::string &title, const relationship &rel)
|
2016-07-27 08:13:09 +08:00
|
|
|
{
|
|
|
|
auto sheet_id = d_->worksheets_.size() + 1;
|
|
|
|
d_->worksheets_.push_back(detail::worksheet_impl(this, sheet_id, title));
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
auto workbook_rel = d_->manifest_.relationship(path("/"), relationship_type::office_document);
|
|
|
|
auto sheet_absoulute_path = workbook_rel.target().path().parent().append(rel.target().path());
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->manifest_.register_override_type(
|
|
|
|
sheet_absoulute_path, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
|
|
|
|
auto ws_rel = d_->manifest_.register_relationship(
|
|
|
|
workbook_rel.target(), relationship_type::worksheet, rel.target(), target_mode::internal);
|
2016-11-01 09:53:22 +08:00
|
|
|
d_->sheet_title_rel_id_map_[title] = ws_rel;
|
|
|
|
|
2017-02-27 20:47:33 +08:00
|
|
|
update_sheet_properties();
|
|
|
|
|
2016-07-27 08:13:09 +08:00
|
|
|
return worksheet(&d_->worksheets_.back());
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
workbook::iterator workbook::begin()
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2014-05-30 08:52:14 +08:00
|
|
|
return iterator(*this, 0);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
workbook::iterator workbook::end()
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2014-05-30 08:52:14 +08:00
|
|
|
return iterator(*this, d_->worksheets_.size());
|
|
|
|
}
|
|
|
|
|
2015-11-23 01:41:27 +08:00
|
|
|
workbook::const_iterator workbook::begin() const
|
|
|
|
{
|
|
|
|
return cbegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
workbook::const_iterator workbook::end() const
|
|
|
|
{
|
|
|
|
return cend();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:52:14 +08:00
|
|
|
workbook::const_iterator workbook::cbegin() const
|
|
|
|
{
|
|
|
|
return const_iterator(*this, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
workbook::const_iterator workbook::cend() const
|
|
|
|
{
|
|
|
|
return const_iterator(*this, d_->worksheets_.size());
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::vector<std::string> workbook::sheet_titles() const
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2015-11-11 07:58:54 +08:00
|
|
|
std::vector<std::string> names;
|
2015-11-01 22:43:01 +08:00
|
|
|
|
|
|
|
for (auto ws : *this)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
names.push_back(ws.title());
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-05-21 22:20:30 +08:00
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::size_t workbook::sheet_count() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->worksheets_.size();
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2015-11-11 07:58:54 +08:00
|
|
|
worksheet workbook::operator[](const std::string &name)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
return sheet_by_title(name);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2014-06-11 05:12:15 +08:00
|
|
|
worksheet workbook::operator[](std::size_t index)
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return sheet_by_index(index);
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::clear()
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
*d_ = detail::workbook_impl();
|
2016-09-10 22:05:06 +08:00
|
|
|
d_->stylesheet_.clear();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
|
|
|
|
2016-07-22 10:14:00 +08:00
|
|
|
bool workbook::operator==(const workbook &rhs) const
|
2014-07-20 04:59:05 +08:00
|
|
|
{
|
2016-07-22 10:14:00 +08:00
|
|
|
return d_.get() == rhs.d_.get();
|
2014-07-20 04:59:05 +08:00
|
|
|
}
|
|
|
|
|
2016-07-22 10:14:00 +08:00
|
|
|
bool workbook::operator!=(const workbook &rhs) const
|
2014-05-21 22:20:30 +08:00
|
|
|
{
|
2016-07-22 10:14:00 +08:00
|
|
|
return d_.get() != rhs.d_.get();
|
2014-05-21 22:20:30 +08:00
|
|
|
}
|
2014-06-16 01:06:47 +08:00
|
|
|
|
2017-03-21 08:17:09 +08:00
|
|
|
void workbook::swap(workbook &right)
|
2014-07-20 04:59:05 +08:00
|
|
|
{
|
2017-03-21 08:17:09 +08:00
|
|
|
auto &left = *this;
|
|
|
|
|
2014-07-24 08:51:28 +08:00
|
|
|
using std::swap;
|
|
|
|
swap(left.d_, right.d_);
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
if (left.d_ != nullptr)
|
|
|
|
{
|
|
|
|
for (auto ws : left)
|
|
|
|
{
|
|
|
|
ws.parent(left);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left.d_->stylesheet_.is_set())
|
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
left.d_->stylesheet_.get().parent = &left;
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (right.d_ != nullptr)
|
|
|
|
{
|
|
|
|
for (auto ws : right)
|
|
|
|
{
|
|
|
|
ws.parent(right);
|
|
|
|
}
|
|
|
|
|
2016-12-30 07:36:29 +08:00
|
|
|
if (right.d_->stylesheet_.is_set())
|
2016-12-24 23:04:57 +08:00
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
right.d_->stylesheet_.get().parent = &right;
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
|
|
|
}
|
2014-07-24 08:51:28 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2014-07-24 08:51:28 +08:00
|
|
|
workbook &workbook::operator=(workbook other)
|
|
|
|
{
|
2017-03-21 08:17:09 +08:00
|
|
|
swap(other);
|
2016-12-30 08:00:27 +08:00
|
|
|
d_->stylesheet_.get().parent = this;
|
2016-12-02 21:37:50 +08:00
|
|
|
|
2014-07-24 08:51:28 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
workbook::workbook(workbook &&other)
|
|
|
|
: workbook(nullptr)
|
2014-07-24 08:51:28 +08:00
|
|
|
{
|
2017-03-21 08:17:09 +08:00
|
|
|
swap(other);
|
2014-07-24 08:51:28 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
workbook::workbook(const workbook &other)
|
|
|
|
: workbook()
|
2014-07-24 08:51:28 +08:00
|
|
|
{
|
|
|
|
*d_.get() = *other.d_.get();
|
2015-11-01 22:43:01 +08:00
|
|
|
|
|
|
|
for (auto ws : *this)
|
2014-07-24 08:51:28 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
ws.parent(*this);
|
2014-07-24 08:51:28 +08:00
|
|
|
}
|
2016-11-04 07:26:11 +08:00
|
|
|
|
2016-12-30 08:00:27 +08:00
|
|
|
d_->stylesheet_.get().parent = this;
|
2014-07-20 04:59:05 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 03:37:34 +08:00
|
|
|
workbook::~workbook()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-03 12:12:18 +08:00
|
|
|
bool workbook::has_theme() const
|
2015-10-19 03:30:46 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->theme_.is_set();
|
2015-10-19 03:30:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const theme &workbook::theme() const
|
2015-10-19 03:30:46 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
return d_->theme_.get();
|
2015-10-19 03:30:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void workbook::theme(const class theme &value)
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->theme_ = value;
|
2017-01-16 08:08:57 +08:00
|
|
|
register_workbook_part(relationship_type::theme);
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::vector<named_range> workbook::named_ranges() const
|
2015-10-19 03:30:46 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
std::vector<xlnt::named_range> named_ranges;
|
2015-11-01 22:43:01 +08:00
|
|
|
|
|
|
|
for (auto ws : *this)
|
2015-10-14 01:56:07 +08:00
|
|
|
{
|
2015-11-01 22:43:01 +08:00
|
|
|
for (auto &ws_named_range : ws.d_->named_ranges_)
|
2015-10-19 03:30:46 +08:00
|
|
|
{
|
|
|
|
named_ranges.push_back(ws_named_range.second);
|
|
|
|
}
|
2015-10-14 01:56:07 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2015-10-19 03:30:46 +08:00
|
|
|
return named_ranges;
|
|
|
|
}
|
|
|
|
|
2016-11-10 08:52:18 +08:00
|
|
|
format workbook::create_format(bool default_format)
|
2016-06-11 01:40:50 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
register_workbook_part(relationship_type::stylesheet);
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().create_format(default_format);
|
2016-06-11 01:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool workbook::has_style(const std::string &name) const
|
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().has_style(name);
|
2015-10-24 02:42:36 +08:00
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-05-16 03:03:02 +08:00
|
|
|
void workbook::clear_styles()
|
|
|
|
{
|
2016-06-11 01:40:50 +08:00
|
|
|
apply_to_cells([](cell c) { c.clear_style(); });
|
2016-05-16 03:03:02 +08:00
|
|
|
}
|
|
|
|
|
2016-05-15 01:57:07 +08:00
|
|
|
void workbook::clear_formats()
|
2016-05-14 02:40:17 +08:00
|
|
|
{
|
2016-06-11 01:40:50 +08:00
|
|
|
apply_to_cells([](cell c) { c.clear_format(); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::apply_to_cells(std::function<void(cell)> f)
|
|
|
|
{
|
|
|
|
for (auto ws : *this)
|
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
for (auto row = ws.lowest_row(); row <= ws.highest_row(); ++row)
|
2016-06-11 01:40:50 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
for (auto column = ws.lowest_column(); column <= ws.highest_column(); ++column)
|
2016-06-11 01:40:50 +08:00
|
|
|
{
|
2016-11-08 10:11:30 +08:00
|
|
|
if (ws.has_cell(cell_reference(column, row)))
|
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
f.operator()(ws.cell(cell_reference(column, row)));
|
2016-11-08 10:11:30 +08:00
|
|
|
}
|
2016-06-11 01:40:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-14 02:40:17 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
format workbook::format(std::size_t format_index)
|
2015-10-29 03:08:54 +08:00
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().format(format_index);
|
2015-10-29 03:08:54 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const format workbook::format(std::size_t format_index) const
|
2015-10-29 03:08:54 +08:00
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().format(format_index);
|
2015-10-29 03:08:54 +08:00
|
|
|
}
|
2015-10-30 01:46:56 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
manifest &workbook::manifest()
|
2015-10-30 01:46:56 +08:00
|
|
|
{
|
|
|
|
return d_->manifest_;
|
|
|
|
}
|
2015-11-01 22:43:01 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const manifest &workbook::manifest() const
|
2015-10-30 01:46:56 +08:00
|
|
|
{
|
|
|
|
return d_->manifest_;
|
|
|
|
}
|
|
|
|
|
2016-12-23 19:51:30 +08:00
|
|
|
std::vector<rich_text> &workbook::shared_strings()
|
2015-10-31 06:54:04 +08:00
|
|
|
{
|
|
|
|
return d_->shared_strings_;
|
|
|
|
}
|
|
|
|
|
2016-12-23 19:51:30 +08:00
|
|
|
const std::vector<rich_text> &workbook::shared_strings() const
|
2015-10-31 06:54:04 +08:00
|
|
|
{
|
|
|
|
return d_->shared_strings_;
|
|
|
|
}
|
|
|
|
|
2016-12-23 19:51:30 +08:00
|
|
|
void workbook::add_shared_string(const rich_text &shared, bool allow_duplicates)
|
2015-10-31 06:54:04 +08:00
|
|
|
{
|
2017-01-16 08:08:57 +08:00
|
|
|
register_workbook_part(relationship_type::shared_string_table);
|
2016-12-24 23:04:57 +08:00
|
|
|
|
|
|
|
if (!allow_duplicates)
|
|
|
|
{
|
|
|
|
// TODO: inefficient, use a set or something?
|
|
|
|
for (auto &s : d_->shared_strings_)
|
|
|
|
{
|
|
|
|
if (s == shared) return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-31 06:54:04 +08:00
|
|
|
d_->shared_strings_.push_back(shared);
|
|
|
|
}
|
|
|
|
|
2016-03-06 10:39:50 +08:00
|
|
|
bool workbook::contains(const std::string &sheet_title) const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
for (auto ws : *this)
|
2016-03-06 10:39:50 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
if (ws.title() == sheet_title) return true;
|
2016-03-06 10:39:50 +08:00
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-03-06 10:39:50 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-08 05:49:02 +08:00
|
|
|
void workbook::thumbnail(const std::vector<std::uint8_t> &thumbnail,
|
2017-01-16 08:08:57 +08:00
|
|
|
const std::string &extension, const std::string &content_type)
|
2016-03-10 17:12:51 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
if (!d_->manifest_.has_relationship(path("/"), relationship_type::thumbnail))
|
|
|
|
{
|
2016-08-12 12:22:14 +08:00
|
|
|
d_->manifest_.register_default_type(extension, content_type);
|
2017-02-08 05:49:02 +08:00
|
|
|
d_->manifest_.register_relationship(uri("/"), relationship_type::thumbnail,
|
2017-01-15 03:09:01 +08:00
|
|
|
uri("docProps/thumbnail.jpeg"), target_mode::internal);
|
2016-12-24 23:04:57 +08:00
|
|
|
}
|
2016-08-06 22:40:17 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
auto thumbnail_rel = d_->manifest_.relationship(path("/"), relationship_type::thumbnail);
|
|
|
|
d_->images_[thumbnail_rel.target().to_string()] = thumbnail;
|
2016-03-10 17:12:51 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const std::vector<std::uint8_t> &workbook::thumbnail() const
|
2016-03-10 17:12:51 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
auto thumbnail_rel = d_->manifest_.relationship(path("/"), relationship_type::thumbnail);
|
|
|
|
return d_->images_.at(thumbnail_rel.target().to_string());
|
2016-03-10 17:12:51 +08:00
|
|
|
}
|
|
|
|
|
2016-11-08 10:11:30 +08:00
|
|
|
style workbook::create_style(const std::string &name)
|
2016-05-04 03:37:34 +08:00
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().create_style(name);
|
2016-05-04 03:37:34 +08:00
|
|
|
}
|
|
|
|
|
2017-03-26 22:30:26 +08:00
|
|
|
style workbook::create_builtin_style(const std::size_t builtin_id)
|
|
|
|
{
|
|
|
|
return d_->stylesheet_.get().create_builtin_style(builtin_id);
|
|
|
|
}
|
|
|
|
|
2016-11-08 10:11:30 +08:00
|
|
|
style workbook::style(const std::string &name)
|
2016-05-15 23:51:32 +08:00
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().style(name);
|
2016-05-15 23:51:32 +08:00
|
|
|
}
|
|
|
|
|
2016-11-08 10:11:30 +08:00
|
|
|
const style workbook::style(const std::string &name) const
|
2016-05-15 23:51:32 +08:00
|
|
|
{
|
2016-12-30 08:00:27 +08:00
|
|
|
return d_->stylesheet_.get().style(name);
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
calendar workbook::base_date() const
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->base_date_;
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void workbook::base_date(calendar base_date)
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->base_date_ = base_date;
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
bool workbook::has_title() const
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->title_.is_set();
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::string workbook::title() const
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->title_.get();
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void workbook::title(const std::string &title)
|
2016-08-03 12:12:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->title_ = title;
|
2016-08-03 12:12:18 +08:00
|
|
|
}
|
|
|
|
|
2016-08-05 13:52:05 +08:00
|
|
|
detail::workbook_impl &workbook::impl()
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return *d_;
|
2016-08-05 13:52:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const detail::workbook_impl &workbook::impl() const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return *d_;
|
2016-08-05 13:52:05 +08:00
|
|
|
}
|
2016-08-03 12:12:18 +08:00
|
|
|
|
2016-08-14 02:45:26 +08:00
|
|
|
bool workbook::has_view() const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->view_.is_set();
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
workbook_view workbook::view() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
if (!d_->view_.is_set())
|
|
|
|
{
|
|
|
|
throw invalid_attribute();
|
|
|
|
}
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->view_.get();
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void workbook::view(const workbook_view &view)
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->view_ = view;
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool workbook::has_code_name() const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->code_name_.is_set();
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::string workbook::code_name() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
if (has_code_name())
|
|
|
|
{
|
|
|
|
throw invalid_attribute();
|
|
|
|
}
|
2016-08-14 02:45:26 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->code_name_.get();
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void workbook::code_name(const std::string &code_name)
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
d_->code_name_ = code_name;
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool workbook::has_file_version() const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->file_version_.is_set();
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::string workbook::app_name() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->file_version_.get().app_name;
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::size_t workbook::last_edited() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->file_version_.get().last_edited;
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::size_t workbook::lowest_edited() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->file_version_.get().lowest_edited;
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
std::size_t workbook::rup_build() const
|
2016-08-14 02:45:26 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return d_->file_version_.get().rup_build;
|
2016-08-14 02:45:26 +08:00
|
|
|
}
|
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
bool workbook::has_calculation_properties() const
|
|
|
|
{
|
|
|
|
return d_->calculation_properties_.is_set();
|
|
|
|
}
|
|
|
|
|
|
|
|
class calculation_properties workbook::calculation_properties() const
|
|
|
|
{
|
|
|
|
return d_->calculation_properties_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void workbook::calculation_properties(const class calculation_properties &props)
|
|
|
|
{
|
|
|
|
d_->calculation_properties_ = props;
|
|
|
|
}
|
|
|
|
|
2017-01-03 08:12:23 +08:00
|
|
|
void workbook::garbage_collect_formulae()
|
|
|
|
{
|
|
|
|
auto any_with_formula = false;
|
|
|
|
|
|
|
|
for (auto ws : *this)
|
|
|
|
{
|
2017-03-24 08:05:25 +08:00
|
|
|
for (auto row : ws.rows(true))
|
2017-01-03 08:12:23 +08:00
|
|
|
{
|
|
|
|
for (auto cell : row)
|
|
|
|
{
|
|
|
|
if (cell.has_formula())
|
|
|
|
{
|
|
|
|
any_with_formula = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (any_with_formula) return;
|
|
|
|
|
|
|
|
auto wb_rel = manifest().relationship(path("/"), relationship_type::office_document);
|
|
|
|
|
|
|
|
if (manifest().has_relationship(wb_rel.target().path(), relationship_type::calculation_chain))
|
|
|
|
{
|
|
|
|
auto calc_chain_rel = manifest().relationship(wb_rel.target().path(), relationship_type::calculation_chain);
|
|
|
|
auto calc_chain_part = manifest().canonicalize({wb_rel, calc_chain_rel});
|
|
|
|
manifest().unregister_override_type(calc_chain_part);
|
|
|
|
manifest().unregister_relationship(wb_rel.target(), calc_chain_rel.id());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-27 20:47:33 +08:00
|
|
|
void workbook::update_sheet_properties()
|
|
|
|
{
|
|
|
|
if (has_extended_property(extended_property::titles_of_parts))
|
|
|
|
{
|
|
|
|
extended_property(extended_property::titles_of_parts, sheet_titles());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_extended_property(extended_property::heading_pairs))
|
|
|
|
{
|
|
|
|
extended_property(extended_property::heading_pairs,
|
|
|
|
std::vector<variant>{variant("Worksheets"), variant(static_cast<int>(sheet_count()))});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-19 03:30:46 +08:00
|
|
|
} // namespace xlnt
|