Handling pre-parsed XLSX file

Package XLSX.jl provides tool to import XLSX file from path name: readxlsx.

However, I struggle handle an XLSX that is first parsed by the file upload functionality in Dash.jl. The resulting parsing from the upload is a string that looks like:

data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQABgAIAAAAIQBi7p1oXg...

What I was first hoping to do was to directly save that parsed content into a .xlsx that could then be read by readxlsx. However, resulting file content is no longer in a valid format. The valid xlsx format should have looked like:

PK     ! bîh^     [Content_Types].xml ¢(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ¬”ËNÃ0E÷HüCä-Jܲ@5í‚Ç*Q>Àēƪc[žiiÿž‰ûB¡j7±ÏÜ{2ñÍh²nm¶‚ˆÆ»R‹ÈÀU^e7/ÅÇì%¿’rZYï e@1__f› ˜q·ÃR4DáAJ¬h>€ãÚÇVßƹªZ¨9ÈÛÁàNVÞ8Ê©ÓãÑÔji){^óã-I‹"{Üv^¥P!XS)bR¹rú—K¾s(¸3Õ`cÞ0†½ÝÎß»¾7M4²©ŠôªZƐk+¿|\|z¿(Ž‹ôPúº6h_-[ž@!‚ÒØ Pk‹´­2nÏ}Ä?£LËð Ýû%áÄßedºždN"m,à¥ÇžDO97*‚~§Èɸ8ÀOíc|n¦ÑaäEøÿöéºóÀBÉÀ!$}‡íàÈé;{ìÐå[ƒîñ–é2þ  ÿÿ PK     ! µU0#ô   L   _rels/.rels ¢(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ¬’MOÃ0†ïHü‡È÷ÕݐBKwAH»!T~€Iܵ£$eÝ¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w­†—úqua*&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W	¥†=™ZÆMYÞbø®ÕBSí­†°·7 ê“Ï›×–¦é
?ˆ9LìÒ™ÈsbgÙ®|

Is there a way to get that first parsed string into a valid format, compatbiel with XLSX.readxlsx?

I think you just need to base64decode everything that follows base64,:

julia> using Base64

julia> String(base64decode("UEsDBBQABgAIAAAAIQBi7p1o"))
"PK\x03\x04\x14\0\x06\0\b\0\0\0!\0b\xee\x9dh"

Thanks! By writing a file that only contains the decoded base64 from the parsed string, it results in a valid xslx file:

    # assuming the file was parsed in the variable `input`
    content_start = findfirst(";base64,", input)[end] + 1 # finds where the base 64 content starts
    raw = base64decode(input[content_start:end])
    open(file.xlsx, "w") do io
        write(io, raw)
    end