From 4d2af8438f2fd3996c832553fd892f381e2145e6 Mon Sep 17 00:00:00 2001 From: myk002 Date: Fri, 26 Mar 2021 19:43:15 -0700 Subject: [PATCH] always read all cells to work around xlsxio bug otherwise xlsxio will return a spurious empty row on next row read --- plugins/xlsxreader.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/xlsxreader.cpp b/plugins/xlsxreader.cpp index d9a781f11..e17be096b 100644 --- a/plugins/xlsxreader.cpp +++ b/plugins/xlsxreader.cpp @@ -115,9 +115,12 @@ int get_row(lua_State *L) { std::string value; auto cells = std::vector(); while (get_next_cell(sheet_handle, value)) { - cells.push_back(value); - if (max_tokens > 0 && cells.size() >= max_tokens) - break; + // read all cells in the row, even if we don't need to; + // otherwise xlsxio will return a spurious empty row on + // next call + if (max_tokens <= 0 || cells.size() < max_tokens) { + cells.push_back(value); + } } Lua::PushVector(L, cells, true); }