XLSX.jl icon indicating copy to clipboard operation
XLSX.jl copied to clipboard

Multiple DataFrames in one sheet

Open vishalhedgevantage opened this issue 2 years ago • 2 comments

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?

vishalhedgevantage avatar Sep 16 '21 12:09 vishalhedgevantage

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

nathanrboyer avatar Aug 10 '22 14:08 nathanrboyer

I think this can be closed @felipenoris?

nilshg avatar Jun 26 '23 08:06 nilshg