< Summary

Information
Class: src/writer.jl
Assembly: Default
File(s): src/writer.jl
Tag: 61_25545638018
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 49
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/writer.jl

#LineLine coverage
 61function write(file::AbstractString, jws::JSONWorksheet; kwargs...)
 32    open(file, "w") do io
 33        write(io, jws; kwargs...)
 4    end
 5end
 186function write(io::IO, jws::JSONWorksheet;
 7               indent = 2,
 8               omit_null::Bool = false,
 9               omit_empty::Bool = false)
 910    JSON.json(io, jws.data;
 11              pretty = indent,
 12              omit_null = omit_null,
 13              omit_empty = omit_empty)
 914    return io
 15end
 16
 217function write(path::String, jwb::JSONWorkbook; kwargs...)
 118    f = splitext(basename(xlsxpath(jwb)))[1]
 119    for s in sheetnames(jwb)
 320        write(joinpath(path, "$(f)_$(s).json"), jwb[s]; kwargs...)
 321    end
 22end
 23
 224function write_xlsx(file::String, jwb::JSONWorkbook; delim = ";", anchor_cell = "A1")
 125    XLSX.openxlsx(file, mode="w") do xf
 26
 127        for (i, s) in enumerate(sheetnames(jwb))
 328            jws = jwb[i]
 329            if i == 1
 130                sheet = xf[1]
 131                XLSX.rename!(sheet, s)
 32            else
 233                sheet = XLSX.addsheet!(xf, s)
 34            end
 35
 336            colnames = pointer_to_colname.(jws.pointer)
 337            columns = []
 338            for p in jws.pointer
 3239                data = get.(jws.data, Ref(p), missing)
 3240                if eltype(data) <: Array
 441                    data = join.(data, delim)
 42                end
 3243                push!(columns, data)
 3244            end
 45
 346            XLSX.writetable!(sheet, columns, colnames, anchor_cell=XLSX.CellRef(anchor_cell))
 347        end
 48    end
 49end

Methods/Properties