mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
add saving to the spreadsheet-load test, fix a bug in the serialiser
This commit is contained in:
parent
d135f35bd4
commit
0915fde090
|
@ -5,7 +5,7 @@
|
||||||
namespace {
|
namespace {
|
||||||
using milliseconds_d = std::chrono::duration<double, std::milli>;
|
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";
|
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";
|
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
|
} // namespace
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
run_test(path_helper::benchmark_file("large.xlsx"));
|
run_test(path_helper::benchmark_file("large.xlsx"));
|
||||||
run_test(path_helper::benchmark_file("very_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"));
|
||||||
}
|
}
|
|
@ -2267,16 +2267,18 @@ void xlsx_producer::write_worksheet(const relationship &rel)
|
||||||
{
|
{
|
||||||
write_attribute("enableFormatConditionsCalculation", props.enable_format_condition_calculation.get());
|
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_start_element(xmlns, "outlinePr");
|
||||||
write_attribute("summaryBelow", "1");
|
write_attribute("summaryBelow", "1");
|
||||||
write_attribute("summaryRight", "1");
|
write_attribute("summaryRight", "1");
|
||||||
write_end_element(xmlns, "outlinePr");
|
write_end_element(xmlns, "outlinePr");
|
||||||
|
|
||||||
|
if (ws.has_page_setup())
|
||||||
|
{
|
||||||
write_start_element(xmlns, "pageSetUpPr");
|
write_start_element(xmlns, "pageSetUpPr");
|
||||||
write_attribute("fitToPage", write_bool(ws.page_setup().fit_to_page()));
|
write_attribute("fitToPage", write_bool(ws.page_setup().fit_to_page()));
|
||||||
write_end_element(xmlns, "pageSetUpPr");
|
write_end_element(xmlns, "pageSetUpPr");
|
||||||
|
}
|
||||||
write_end_element(xmlns, "sheetPr");
|
write_end_element(xmlns, "sheetPr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user