mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
fix minor issues and configure script
This commit is contained in:
parent
21315ce803
commit
990c2a926f
|
@ -6,10 +6,11 @@ endif()
|
||||||
|
|
||||||
project(xlnt)
|
project(xlnt)
|
||||||
|
|
||||||
option(SHARED "Set to OFF to build static libraries" ON)
|
option(SHARED "Set to ON to build shared libraries" OFF)
|
||||||
option(BUILD_EXAMPLES "Build examples" OFF)
|
option(BUILD_EXAMPLES "Build examples" OFF)
|
||||||
option(BUILD_TESTS "Build tests runner" OFF)
|
option(BUILD_TESTS "Build tests runner" OFF)
|
||||||
option(AUTORUN_TESTS "Automatically run tests after building" OFF)
|
option(AUTORUN_TESTS "Automatically run tests after building" OFF)
|
||||||
|
option(COVERAGE "Create coverage files" OFF)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)
|
||||||
|
|
|
@ -63,7 +63,7 @@ if(SHARED)
|
||||||
target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1)
|
target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1)
|
||||||
add_definitions(-DXLNT_SHARED)
|
add_definitions(-DXLNT_SHARED)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\"")
|
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /MD")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
||||||
|
|
10
configure
vendored
10
configure
vendored
|
@ -73,6 +73,8 @@ def parse_args(args):
|
||||||
|
|
||||||
if option == '--shared':
|
if option == '--shared':
|
||||||
options['SHARED'] = 1
|
options['SHARED'] = 1
|
||||||
|
elif option == '--static':
|
||||||
|
options['SHARED'] = 0
|
||||||
elif option == '--build-tests':
|
elif option == '--build-tests':
|
||||||
options['BUILD_TESTS'] = 1
|
options['BUILD_TESTS'] = 1
|
||||||
elif option == '--autotest':
|
elif option == '--autotest':
|
||||||
|
@ -81,8 +83,10 @@ def parse_args(args):
|
||||||
options['COVERAGE'] = 1
|
options['COVERAGE'] = 1
|
||||||
elif option == '--build-examples':
|
elif option == '--build-examples':
|
||||||
options['BUILD_EXAMPLES'] = 1
|
options['BUILD_EXAMPLES'] = 1
|
||||||
if option == '--prefix':
|
elif option.startswith('--prefix='):
|
||||||
options['CMAKE_INSTALL_PREFIX'] = args.pop(len(args) - 1)
|
options['CMAKE_INSTALL_PREFIX'] = option.split('=')[1]
|
||||||
|
else:
|
||||||
|
print('skipping unknown option: {}'.format(option))
|
||||||
|
|
||||||
return options, generator
|
return options, generator
|
||||||
|
|
||||||
|
@ -112,6 +116,8 @@ def main():
|
||||||
cmake_scripts_dir = '../cmake' # relative to build_dir
|
cmake_scripts_dir = '../cmake' # relative to build_dir
|
||||||
command.append(cmake_scripts_dir)
|
command.append(cmake_scripts_dir)
|
||||||
|
|
||||||
|
print(' '.join(command))
|
||||||
|
|
||||||
subprocess.call(command, cwd=build_dir)
|
subprocess.call(command, cwd=build_dir)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -174,6 +174,7 @@ class XLNT_CLASS workbook
|
||||||
// named ranges
|
// named ranges
|
||||||
std::vector<named_range> get_named_ranges() const;
|
std::vector<named_range> get_named_ranges() const;
|
||||||
void create_named_range(const std::string &name, worksheet worksheet, const range_reference &reference);
|
void create_named_range(const std::string &name, worksheet worksheet, const range_reference &reference);
|
||||||
|
void create_named_range(const std::string &name, worksheet worksheet, const std::string &reference_string);
|
||||||
bool has_named_range(const std::string &name) const;
|
bool has_named_range(const std::string &name) const;
|
||||||
range get_named_range(const std::string &name);
|
range get_named_range(const std::string &name);
|
||||||
void remove_named_range(const std::string &name);
|
void remove_named_range(const std::string &name);
|
||||||
|
|
|
@ -37,9 +37,9 @@ class XLNT_CLASS range_reference
|
||||||
static range_reference make_absolute(const range_reference &relative_reference);
|
static range_reference make_absolute(const range_reference &relative_reference);
|
||||||
|
|
||||||
range_reference();
|
range_reference();
|
||||||
range_reference(const std::string &range_string);
|
explicit range_reference(const std::string &range_string);
|
||||||
range_reference(const char *range_string);
|
explicit range_reference(const char *range_string);
|
||||||
range_reference(const std::pair<cell_reference, cell_reference> &reference_pair);
|
explicit range_reference(const std::pair<cell_reference, cell_reference> &reference_pair);
|
||||||
range_reference(const cell_reference &start, const cell_reference &end);
|
range_reference(const cell_reference &start, const cell_reference &end);
|
||||||
range_reference(column_t column_index_start, row_t row_index_start, column_t column_index_end, row_t row_index_end);
|
range_reference(column_t column_index_start, row_t row_index_start, column_t column_index_end, row_t row_index_end);
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,9 @@ class XLNT_CLASS worksheet
|
||||||
// container
|
// container
|
||||||
cell get_cell(const cell_reference &reference);
|
cell get_cell(const cell_reference &reference);
|
||||||
const cell get_cell(const cell_reference &reference) const;
|
const cell get_cell(const cell_reference &reference) const;
|
||||||
|
range get_range(const std::string &reference_string);
|
||||||
range get_range(const range_reference &reference);
|
range get_range(const range_reference &reference);
|
||||||
|
const range get_range(const std::string &reference_string) const;
|
||||||
const range get_range(const range_reference &reference) const;
|
const range get_range(const range_reference &reference) const;
|
||||||
range get_squared_range(column_t min_col, row_t min_row, column_t max_col, row_t max_row);
|
range get_squared_range(column_t min_col, row_t min_row, column_t max_col, row_t max_row);
|
||||||
const range get_squared_range(column_t min_col, row_t min_row, column_t max_col, row_t max_row) const;
|
const range get_squared_range(column_t min_col, row_t min_row, column_t max_col, row_t max_row) const;
|
||||||
|
@ -319,6 +321,7 @@ class XLNT_CLASS worksheet
|
||||||
std::string unique_sheet_name(const std::string &value) const;
|
std::string unique_sheet_name(const std::string &value) const;
|
||||||
|
|
||||||
// named range
|
// named range
|
||||||
|
void create_named_range(const std::string &name, const std::string &reference_string);
|
||||||
void create_named_range(const std::string &name, const range_reference &reference);
|
void create_named_range(const std::string &name, const range_reference &reference);
|
||||||
bool has_named_range(const std::string &name);
|
bool has_named_range(const std::string &name);
|
||||||
range get_named_range(const std::string &name);
|
range get_named_range(const std::string &name);
|
||||||
|
@ -340,8 +343,10 @@ class XLNT_CLASS worksheet
|
||||||
// void add_chart(chart chart);
|
// void add_chart(chart chart);
|
||||||
|
|
||||||
// cell merge
|
// cell merge
|
||||||
|
void merge_cells(const std::string &reference_string);
|
||||||
void merge_cells(const range_reference &reference);
|
void merge_cells(const range_reference &reference);
|
||||||
void merge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
|
void merge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
|
||||||
|
void unmerge_cells(const std::string &reference_string);
|
||||||
void unmerge_cells(const range_reference &reference);
|
void unmerge_cells(const range_reference &reference);
|
||||||
void unmerge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
|
void unmerge_cells(column_t start_column, row_t start_row, column_t end_column, row_t end_row);
|
||||||
std::vector<range_reference> get_merged_ranges() const;
|
std::vector<range_reference> get_merged_ranges() const;
|
||||||
|
@ -380,6 +385,7 @@ class XLNT_CLASS worksheet
|
||||||
|
|
||||||
// auto filter
|
// auto filter
|
||||||
range_reference get_auto_filter() const;
|
range_reference get_auto_filter() const;
|
||||||
|
void auto_filter(const std::string &range_string);
|
||||||
void auto_filter(const xlnt::range &range);
|
void auto_filter(const xlnt::range &range);
|
||||||
void auto_filter(const range_reference &reference);
|
void auto_filter(const range_reference &reference);
|
||||||
void unset_auto_filter();
|
void unset_auto_filter();
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
auto ws = wb.create_sheet();
|
auto ws = wb.create_sheet();
|
||||||
ws.get_cell("F42").set_value("hello");
|
ws.get_cell("F42").set_value("hello");
|
||||||
ws.get_auto_filter() = "A1:F1";
|
ws.auto_filter("A1:F1");
|
||||||
|
|
||||||
xlnt::workbook_serializer serializer(wb);
|
xlnt::workbook_serializer serializer(wb);
|
||||||
auto observed = serializer.write_workbook();
|
auto observed = serializer.write_workbook();
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool worksheet_serializer::read_worksheet(const xml_document &xml)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet_.merge_cells(merge_cell_node.get_attribute("ref"));
|
sheet_.merge_cells(range_reference(merge_cell_node.get_attribute("ref")));
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,11 @@ int workbook::get_index(xlnt::worksheet worksheet)
|
||||||
throw std::runtime_error("worksheet isn't owned by this workbook");
|
throw std::runtime_error("worksheet isn't owned by this workbook");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
void workbook::create_named_range(const std::string &name, worksheet range_owner, const range_reference &reference)
|
void workbook::create_named_range(const std::string &name, worksheet range_owner, const range_reference &reference)
|
||||||
{
|
{
|
||||||
auto match = get_sheet_by_name(range_owner.get_title());
|
auto match = get_sheet_by_name(range_owner.get_title());
|
||||||
|
|
|
@ -54,6 +54,11 @@ std::string worksheet::unique_sheet_name(const std::string &value) const
|
||||||
return append == 0 ? value : value + std::to_string(append);
|
return append == 0 ? value : value + std::to_string(append);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void worksheet::create_named_range(const std::string &name, const std::string &reference_string)
|
||||||
|
{
|
||||||
|
create_named_range(name, range_reference(reference_string));
|
||||||
|
}
|
||||||
|
|
||||||
void worksheet::create_named_range(const std::string &name, const range_reference &reference)
|
void worksheet::create_named_range(const std::string &name, const range_reference &reference)
|
||||||
{
|
{
|
||||||
std::vector<named_range::target> targets;
|
std::vector<named_range::target> targets;
|
||||||
|
@ -63,7 +68,7 @@ void worksheet::create_named_range(const std::string &name, const range_referenc
|
||||||
|
|
||||||
range worksheet::operator()(const xlnt::cell_reference &top_left, const xlnt::cell_reference &bottom_right)
|
range worksheet::operator()(const xlnt::cell_reference &top_left, const xlnt::cell_reference &bottom_right)
|
||||||
{
|
{
|
||||||
return get_range({ top_left, bottom_right });
|
return get_range(range_reference(top_left, bottom_right));
|
||||||
}
|
}
|
||||||
|
|
||||||
cell worksheet::operator[](const cell_reference &ref)
|
cell worksheet::operator[](const cell_reference &ref)
|
||||||
|
@ -86,6 +91,11 @@ const margins &worksheet::get_page_margins() const
|
||||||
return d_->page_margins_;
|
return d_->page_margins_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void worksheet::auto_filter(const std::string &reference_string)
|
||||||
|
{
|
||||||
|
auto_filter(range_reference(reference_string));
|
||||||
|
}
|
||||||
|
|
||||||
void worksheet::auto_filter(const range_reference &reference)
|
void worksheet::auto_filter(const range_reference &reference)
|
||||||
{
|
{
|
||||||
d_->auto_filter_ = reference;
|
d_->auto_filter_ = reference;
|
||||||
|
@ -321,11 +331,21 @@ range_reference worksheet::calculate_dimension() const
|
||||||
return range_reference(lowest_column, lowest_row, highest_column, highest_row);
|
return range_reference(lowest_column, lowest_row, highest_column, highest_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
range worksheet::get_range(const std::string &reference_string)
|
||||||
|
{
|
||||||
|
return get_range(range_reference(reference_string));
|
||||||
|
}
|
||||||
|
|
||||||
range worksheet::get_range(const range_reference &reference)
|
range worksheet::get_range(const range_reference &reference)
|
||||||
{
|
{
|
||||||
return range(*this, reference);
|
return range(*this, reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const range worksheet::get_range(const std::string &reference_string) const
|
||||||
|
{
|
||||||
|
return get_range(range_reference(reference_string));
|
||||||
|
}
|
||||||
|
|
||||||
const range worksheet::get_range(const range_reference &reference) const
|
const range worksheet::get_range(const range_reference &reference) const
|
||||||
{
|
{
|
||||||
return range(*this, reference);
|
return range(*this, reference);
|
||||||
|
@ -355,6 +375,16 @@ relationship worksheet::create_relationship(relationship::type type, const std::
|
||||||
return d_->relationships_.back();
|
return d_->relationships_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void worksheet::merge_cells(const std::string &reference_string)
|
||||||
|
{
|
||||||
|
merge_cells(range_reference(reference_string));
|
||||||
|
}
|
||||||
|
|
||||||
|
void worksheet::unmerge_cells(const std::string &reference_string)
|
||||||
|
{
|
||||||
|
unmerge_cells(range_reference(reference_string));
|
||||||
|
}
|
||||||
|
|
||||||
void worksheet::merge_cells(const range_reference &reference)
|
void worksheet::merge_cells(const range_reference &reference)
|
||||||
{
|
{
|
||||||
d_->merged_cells_.push_back(reference);
|
d_->merged_cells_.push_back(reference);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user