Skip to content

Commit

Permalink
add saving to the spreadsheet-load test, fix a bug in the serialiser
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Mar 1, 2020
1 parent d135f35 commit 0915fde
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
27 changes: 26 additions & 1 deletion benchmarks/spreadsheet-load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace {
using milliseconds_d = std::chrono::duration<double, std::milli>;

void run_test(const xlnt::path &file, int runs = 10)
void run_load_test(const xlnt::path &file, int runs = 10)
{
std::cout << file.string() << "\n\n";

Expand All @@ -24,10 +24,35 @@ void run_test(const xlnt::path &file, int runs = 10)
std::cout << milliseconds_d(test_timings.back()).count() << " ms\n";
}
}

void run_save_test(const xlnt::path &file, int runs = 10)
{
std::cout << file.string() << "\n\n";

xlnt::workbook wb;
wb.load(file);
const xlnt::path save_path(file.filename());

std::vector<std::chrono::steady_clock::duration> test_timings;

for (int i = 0; i < runs; ++i)
{
auto start = std::chrono::steady_clock::now();

wb.save(save_path);

auto end = std::chrono::steady_clock::now();
test_timings.push_back(end - start);
std::cout << milliseconds_d(test_timings.back()).count() << " ms\n";
}
}
} // namespace

int main()
{
run_test(path_helper::benchmark_file("large.xlsx"));
run_test(path_helper::benchmark_file("very_large.xlsx"));

run_save_test(path_helper::benchmark_file("large.xlsx"));
run_save_test(path_helper::benchmark_file("very_large.xlsx"));
}
12 changes: 7 additions & 5 deletions source/detail/serialization/xlsx_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2267,16 +2267,18 @@ void xlsx_producer::write_worksheet(const relationship &rel)
{
write_attribute("enableFormatConditionsCalculation", props.enable_format_condition_calculation.get());
}

// outlinePr is optional in the spec but is being written every time?
write_start_element(xmlns, "outlinePr");
write_attribute("summaryBelow", "1");
write_attribute("summaryRight", "1");
write_end_element(xmlns, "outlinePr");

write_start_element(xmlns, "pageSetUpPr");
write_attribute("fitToPage", write_bool(ws.page_setup().fit_to_page()));
write_end_element(xmlns, "pageSetUpPr");

if (ws.has_page_setup())
{
write_start_element(xmlns, "pageSetUpPr");
write_attribute("fitToPage", write_bool(ws.page_setup().fit_to_page()));
write_end_element(xmlns, "pageSetUpPr");
}
write_end_element(xmlns, "sheetPr");
}

Expand Down

0 comments on commit 0915fde

Please sign in to comment.