Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading of a comment with an author in xlsx. #562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/roo/excelx/comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added test/files/comments-with-author.xlsx
Binary file not shown.
11 changes: 11 additions & 0 deletions test/helpers/test_comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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