summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet/Spreadsheet.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-03-21 20:38:08 +0330
committerAndreas Kling <kling@serenityos.org>2021-03-22 07:43:58 +0100
commit3c151b3de6ab24ea07de8e9d75e1b919635618e0 (patch)
treeb97a09fecddf206890ca6084c0a18a8faf34cf5b /Userland/Applications/Spreadsheet/Spreadsheet.cpp
parent3bbcde9192ac2a73edd48556e41d8403827e3d3a (diff)
downloadserenity-3c151b3de6ab24ea07de8e9d75e1b919635618e0.zip
Spreadsheet: Add an import wizard, and add support for custom CSV files
Fixes the import half of #4269.
Diffstat (limited to 'Userland/Applications/Spreadsheet/Spreadsheet.cpp')
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index d66f982d39..e5acbcc054 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -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()) {