From cee91fdebeb5c86b623aa05c4074adb2fe3854f2 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 30 Sep 2024 16:31:29 -0400 Subject: [PATCH] xlsxtomd: omit header row (optional) Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/xlsxtomd.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/gpt4all-chat/src/xlsxtomd.cpp b/gpt4all-chat/src/xlsxtomd.cpp index 814bbb5b..fe6c1021 100644 --- a/gpt4all-chat/src/xlsxtomd.cpp +++ b/gpt4all-chat/src/xlsxtomd.cpp @@ -127,29 +127,14 @@ QString XLSXToMD::toMarkdown(const QString &xlsxFilePath) continue; } - // Assume the first row is the header - int headerRow = firstRow; - - // Collect headers - QStringList headers; - for (int col = firstCol; col <= lastCol; ++col) { - QString header = getCellValue(sheet, headerRow, col); - headers << header; - } - - // Create Markdown header row - QString headerRowMarkdown = "|" + headers.join("|") + "|"; - markdown += headerRowMarkdown + "\n"; - - // Create Markdown separator row + // Separator row (no header) QStringList separators; - for (int i = 0; i < headers.size(); ++i) - separators << "---"; - QString separatorRow = "|" + separators.join("|") + "|"; - markdown += separatorRow + "\n"; + for (int col = firstCol; col <= lastCol; ++col) + separators << u"---"_s; + markdown += u"|%1|\n"_s.arg(separators.join(u'|')); - // Iterate through data rows (starting from the row after header) - for (int row = headerRow + 1; row <= lastRow; ++row) { + // Iterate through data rows + for (int row = 0; row <= lastRow; ++row) { QStringList rowData; for (int col = firstCol; col <= lastCol; ++col) { QString cellText = getCellValue(sheet, row, col);