Skip to content

Commit 4dbebf2

Browse files
authored
Merge pull request #112 from kenichi/inline_string_values
parse inline string values
2 parents 6c70655 + c66ac1e commit 4dbebf2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/xlsxir/parse_worksheet.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ defmodule Xlsxir.ParseWorksheet do
6969
case attr do
7070
{:attribute, 's', _, _, style} ->
7171
Map.put(acc, "s", find_styles(styles_tid, List.to_integer(style)))
72+
7273
{:attribute, key, _, _, ref} ->
7374
Map.put(acc, to_string(key), ref)
7475
end
@@ -91,6 +92,9 @@ defmodule Xlsxir.ParseWorksheet do
9192
%{state | value_type: nil}
9293
end
9394

95+
def sax_event_handler({:startElement, _, 'is', _, _}, state, _, _),
96+
do: %{state | value_type: :value}
97+
9498
def sax_event_handler({:characters, value}, state, _, _) do
9599
case state do
96100
nil -> nil

test/xlsxir_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,14 @@ defmodule XlsxirTest do
147147
[123, "baz"]
148148
]
149149
end
150+
151+
test "parses inline strings" do
152+
{:ok, pid} = multi_extract("test/test_data/noShared.xlsx", 0)
153+
on_exit(fn -> close(pid) end)
154+
map = get_map(pid)
155+
156+
assert map["A1"] == "Generated Doc"
157+
assert map["B2"] == "pre 2008"
158+
assert map["B3"] == "https://msdn.microsoft.com/en-us/library/office/gg278314.aspx"
159+
end
150160
end

0 commit comments

Comments
 (0)