You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
KeyError: key "r:id" not found when the relationships namespace uses a prefix other than r (regression since 0.10) #507
Since moving from EzXML to XML.jl, XLSX.jl looks up relationship attributes by the literal qualified name "r:id". Under the XML Namespaces spec the prefix can be anything, as long as it is bound to http://schemas.openxmlformats.org/officeDocument/2006/relationships. Some report generators write the sheet entries in xl/workbook.xml like this:
The script writes an ordinary file with XLSX.jl and then rewrites the <sheet> element so it uses a different prefix that is bound to the same namespace:
using XLSX, ZipArchives
src, dst ="plain.xlsx", "prefixed.xlsx"
XLSX.writetable(src, "Sheet1"=> [(a=[1,2], b=["x","y"])]...; overwrite=true)
r =ZipReader(read(src))
ZipWriter(dst) do w
for name inzip_names(r)
data =zip_readentry(r, name)
if name =="xl/workbook.xml"
s =replace(String(data), r"<sheet ([^>]*?)r:id="=>s"<sheet \1xmlns:relationships=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" relationships:id=")
data =Vector{UInt8}(s)
endzip_writefile(w, name, data)
endend
XLSX.readtable(src, "Sheet1") # works
XLSX.readtable(dst, "Sheet1") # KeyError: key "r:id" not found
Versions
XLSX.jl 0.13.4 fails; 0.10.4 works on the same file
Julia 1.13.1, Linux x86_64
Notes
The failing lookup is src/worksheet.jl:73 (a["r:id"]). The same literal-prefix pattern also appears in other places, for example src/relationship.jl:134 and src/exceltables.jl:132,765. So files like this would probably fail in those places too once the sheet lookup is fixed. Resolving the attribute by namespace URI + local name (id), or accepting any prefix that is bound to the relationships namespace, would fix all of them.
Thanks for the clear report and the reproducer, @larsJonsen. You were right: since 0.11, XLSX.jl looked up the literal name r:id and didn't handle other prefixes bound to the relationships namespace.
0.10.4 worked here partly by luck. Under EzXML, node["r:id"] looked up the prefix r and then matched the attribute by its namespace URI. Your reproducer starts from a writetable file, whose <workbook> root still declares xmlns:r, so the lookup succeeded. A file that declares the namespace only as relationships: fails in 0.10.4 too, with unknown namespace prefix: 'r'.
The fix (#508) reads relationship ids under any prefix. It covers every place you listed (worksheet.jl, relationship.jl:134, exceltables.jl:132 and :765) plus a few more: table-part ids, external references and external-book paths. While auditing, I also fixed several places where XLSX.jl writes into parts it didn't create:
the r prefix is now declared wherever XLSX.jl writes an r:id
images and text boxes added to an existing drawing now use that drawing's own prefixes
copysheet! no longer adds a second uid attribute when the source sheet uses a different prefix for it
Your reproducer now reads correctly, in both forms: with xmlns:r still on the root, and with only relationships:. Files written back from it open in Excel without repair. If you could try the branch with output from your report generator, that would be very helpful.
Activity
TimG1964 commentedon Nov 22, 2026
Thanks for the clear report and the reproducer, @larsJonsen. You were right: since 0.11, XLSX.jl looked up the literal name
r:idand didn't handle other prefixes bound to the relationships namespace.0.10.4 worked here partly by luck. Under EzXML,
node["r:id"]looked up the prefixrand then matched the attribute by its namespace URI. Your reproducer starts from awritetablefile, whose<workbook>root still declaresxmlns:r, so the lookup succeeded. A file that declares the namespace only asrelationships:fails in 0.10.4 too, withunknown namespace prefix: 'r'.The fix (#508) reads relationship ids under any prefix. It covers every place you listed (
worksheet.jl,relationship.jl:134,exceltables.jl:132and:765) plus a few more: table-part ids, external references and external-book paths. While auditing, I also fixed several places where XLSX.jl writes into parts it didn't create:rprefix is now declared wherever XLSX.jl writes anr:idcopysheet!no longer adds a second uid attribute when the source sheet uses a different prefix for itYour reproducer now reads correctly, in both forms: with
xmlns:rstill on the root, and with onlyrelationships:. Files written back from it open in Excel without repair. If you could try the branch with output from your report generator, that would be very helpful.Fix issue #507.