在 Julia 中,是否可以将数组导出到单独的 Excel 工作表中。假设我有以下两个数组
A = ones(4,4)
B = ones(5,100)
我想将数组 A 保存在同一 Excel 文件的工作表 A 中,将数组 B 保存在工作表 B 中。
最佳答案
这里是:
using Pkg
Pkg.add("XLSX")
using XLSX
A = reshape(1:20,4,5)
B = reshape(51:100,10,5)
function fill_sheet(sheet, arr)
for ind in CartesianIndices(arr)
XLSX.setdata!(sheet, XLSX.CellRef(ind[1], ind[2]), arr[ind])
end
end
XLSX.openxlsx("sample2.xlsx", mode="w") do xf
s = XLSX.addsheet!(xf,"SheetName_A")
fill_sheet(s,A)
s = XLSX.addsheet!(xf,"SheetName_B")
fill_sheet(s,B)
end
关于excel - 在 Julia 中将数组导出到 Excel 工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55536028/