Skip to content

Respect xml:space="preserve" (#43) #45

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TimG1964
Copy link
Contributor

This PR fixes the issue reported in #43. I've added extra tests, too.

One caveat in testing: I had to change one test (only):

    @testset "next and prev" begin
        @test XML.prev(doc[1]) === data

I had to change the condition from === to only ==. With this single change, tests now all pass locally.

I've also checked that this PR works well with XLSX.jl downstream and all XLSX tests also pass locally.

With this PR, XLSX now properly reads a workbook like this:
image
which has leading and trailing whitespace in column A and, in column B, only has whitespace.
Reading this XLSX file now works correctly:

julia> f=XLSX.openxlsx(raw"C:\Users\tim\OneDrive\Documents\Julia\XLSX\sstTest.xlsx", mode="rw")
XLSXFile("sstTest.xlsx") containing 1 Worksheet
            sheetname size          range        
-------------------------------------------------
               Sheet1 5x2           A1:B5        

julia> f[1][:]
5×2 Matrix{Any}:
 "  hello"    "    "
 "  hello  "  "    "
 " hello\">"  "    "
 "hello\">"   "    "
 "  hello"    "    "

Previously, leading and trailing spaces would be trimmed, and cells containing only whitespace would become missing.

I'm afraid I can't match the simple elegance of your coding style, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant