Skip to content

Commit

Permalink
Merge pull request #112 from kenichi/inline_string_values
Browse files Browse the repository at this point in the history
parse inline string values
  • Loading branch information
jsonkenl authored Jan 18, 2023
2 parents 6c70655 + c66ac1e commit 4dbebf2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/xlsxir/parse_worksheet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ defmodule Xlsxir.ParseWorksheet do
case attr do
{:attribute, 's', _, _, style} ->
Map.put(acc, "s", find_styles(styles_tid, List.to_integer(style)))

{:attribute, key, _, _, ref} ->
Map.put(acc, to_string(key), ref)
end
Expand All @@ -91,6 +92,9 @@ defmodule Xlsxir.ParseWorksheet do
%{state | value_type: nil}
end

def sax_event_handler({:startElement, _, 'is', _, _}, state, _, _),
do: %{state | value_type: :value}

def sax_event_handler({:characters, value}, state, _, _) do
case state do
nil -> nil
Expand Down
10 changes: 10 additions & 0 deletions test/xlsxir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,14 @@ defmodule XlsxirTest do
[123, "baz"]
]
end

test "parses inline strings" do
{:ok, pid} = multi_extract("test/test_data/noShared.xlsx", 0)
on_exit(fn -> close(pid) end)
map = get_map(pid)

assert map["A1"] == "Generated Doc"
assert map["B2"] == "pre 2008"
assert map["B3"] == "https://msdn.microsoft.com/en-us/library/office/gg278314.aspx"
end
end

0 comments on commit 4dbebf2

Please sign in to comment.