add saving to the spreadsheet-load test, fix a bug in the serialiser

This commit is contained in:
JCrawfy 2020-03-01 20:43:56 +13:00
parent d135f35bd4
commit 0915fde090
2 changed files with 33 additions and 6 deletions

View File

@ -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";
@ -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"));
}

View File

@ -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");
}