diff --git a/lib/roo/excelx/comments.rb b/lib/roo/excelx/comments.rb index 65044a94..c37097a5 100644 --- a/lib/roo/excelx/comments.rb +++ b/lib/roo/excelx/comments.rb @@ -13,7 +13,7 @@ def extract_comments return {} unless doc_exists? doc.xpath('//comments/commentList/comment').each_with_object({}) do |comment, hash| - value = (comment.at_xpath('./text/r/t') || comment.at_xpath('./text/t')).text + value = comment.xpath('./text/r/t', './text/t').text hash[::Roo::Utils.ref_to_key(comment['ref'].to_s)] = value end end diff --git a/test/files/comments-with-author.xlsx b/test/files/comments-with-author.xlsx new file mode 100644 index 00000000..6377aaf8 Binary files /dev/null and b/test/files/comments-with-author.xlsx differ diff --git a/test/helpers/test_comments.rb b/test/helpers/test_comments.rb index 2e267862..e204b1aa 100644 --- a/test/helpers/test_comments.rb +++ b/test/helpers/test_comments.rb @@ -40,4 +40,15 @@ def test_comments_from_google_sheet_exported_as_xlsx assert_equal expected_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}" end end + + def test_excel_comment_with_author + options = { name: "comments-with-author", format: [:excelx] } + expexted_comments = [ + [6, 2, "Eli Wang:\ncomment with author"] + ] + + with_each_spreadsheet(options) do |oo| + assert_equal expexted_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}" + end + end end