felipenoris / XLSX.jl

Excel file reader and writer for the Julia language.
https://felipenoris.github.io/XLSX.jl/stable
Other
271 stars 56 forks source link

Multiple DataFrames in one sheet #180

Open vishalhedgevantage opened 2 years ago

vishalhedgevantage commented 2 years ago

I am not able to find a way to write multiple dataframes in one excel sheet. Is there any existing method that I can use for doing this?

nathanrboyer commented 2 years ago

Yes, there is an anchor_cell keyword argument for the writetable! function that you can use to write multiple dataframes per sheet.

using DataFrames, XLSX
df1 = DataFrame(a = [1,2,3], b = [4,5,6])
df2 = DataFrame(c = [7,8,9], d = [10,11,12])
XLSX.openxlsx("path/to/file.xlsx", mode="w") do file
    XLSX.writetable!(file[1], df1)
    XLSX.writetable!(file[1], df2, anchor_cell=XLSX.CellRef("C1"))
end
nilshg commented 1 year ago

I think this can be closed @felipenoris?