From 225bc96d2162fc639afc63cff8e1ee7e410ec907 Mon Sep 17 00:00:00 2001 From: suexcxine Date: Sun, 25 Jul 2021 00:03:06 +0800 Subject: [PATCH] Fix last row missed issue and infinite loop problem --- lib/exoffice/parser/excel_2003.ex | 2 +- lib/exoffice/parser/excel_2003/loader.ex | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/exoffice/parser/excel_2003.ex b/lib/exoffice/parser/excel_2003.ex index ee1893d..115fa6c 100644 --- a/lib/exoffice/parser/excel_2003.ex +++ b/lib/exoffice/parser/excel_2003.ex @@ -49,7 +49,7 @@ defmodule Exoffice.Parser.Excel2003 do """ def count_rows(pid) do - Xlsxir.get_multi_info(pid, :rows) + :ets.info(pid, :size) end @doc """ diff --git a/lib/exoffice/parser/excel_2003/loader.ex b/lib/exoffice/parser/excel_2003/loader.ex index dc69c82..1e7c9a8 100644 --- a/lib/exoffice/parser/excel_2003/loader.ex +++ b/lib/exoffice/parser/excel_2003/loader.ex @@ -193,7 +193,7 @@ defmodule Exoffice.Parser.Excel2003.Loader do # add cell case :ets.match(pid, {row, :"$1"}) do [[cells]] -> - :ets.insert(pid, {row, cells ++ [[column_string <> to_string(row), value]]}) + :ets.insert(pid, {row, [[column_string <> to_string(row), value]] ++ cells}) _ -> :ets.insert(pid, {row, [[column_string <> to_string(row), value]]}) @@ -218,7 +218,7 @@ defmodule Exoffice.Parser.Excel2003.Loader do # add cell case :ets.match(pid, {row, :"$1"}) do [[cells]] -> - :ets.insert(pid, {row, cells ++ [[column_string <> to_string(row), value]]}) + :ets.insert(pid, {row, [[column_string <> to_string(row), value]] ++ cells}) _ -> :ets.insert(pid, {row, [[column_string <> to_string(row), value]]}) @@ -241,7 +241,7 @@ defmodule Exoffice.Parser.Excel2003.Loader do # add cell case :ets.match(pid, {row, :"$1"}) do [[cells]] -> - :ets.insert(pid, {row, cells ++ [[column_string <> to_string(row), nil]]}) + :ets.insert(pid, {row, [[column_string <> to_string(row), nil]] ++ cells}) _ -> :ets.insert(pid, {row, [[column_string <> to_string(row), nil]]})