1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

Spreadsheet: Add an import wizard, and add support for custom CSV files

Fixes the import half of #4269.
This commit is contained in:
AnotherTest 2021-03-21 20:38:08 +03:30 committed by Andreas Kling
parent 3bbcde9192
commit 3c151b3de6
7 changed files with 601 additions and 52 deletions

View file

@ -636,7 +636,13 @@ RefPtr<Sheet> Sheet::from_xsv(const Reader::XSV& xsv, Workbook& workbook)
auto rows = xsv.size();
auto sheet = adopt(*new Sheet(workbook));
sheet->m_columns = cols;
if (xsv.has_explicit_headers()) {
sheet->m_columns = cols;
} else {
sheet->m_columns.ensure_capacity(cols.size());
for (size_t i = 0; i < cols.size(); ++i)
sheet->m_columns.append(convert_to_string(i));
}
for (size_t i = 0; i < max(rows, Sheet::default_row_count); ++i)
sheet->add_row();
if (sheet->columns_are_standard()) {