XLSX.jl: writing sheets from vectors

See below. It ends up a little complicated, building the NamedTuple, then splatting it into writetable

using DataFrames
import XLSX

report_vec = ["REPORT A", "REPORT B"]
dfs = [DataFrame(a=[1, 2, 3]), DataFrame(b=[4, 5, 6])]

nt = (;(Symbol(name) => (collect(eachcol(df)), names(df)) for (name, df) in zip(report_vec, dfs))...)
XLSX.writetable("test.xlsx"; nt...)
2 Likes