Generate XLSX using Lists.
Closed this issue · 3 comments
mbenatti commented
- This is not an issue, this is a propose to enhancement and a question.
There's a function to generate the spreadsheet passing only a list and then auto generate a XLSX that each line(cell line) represents each value in the List???
unti1x commented
data = [1,2,3,4,5]
rows = Enum.map data, fn(x)->[x] end
sheet = %Sheet{rows: rows}
Is that what you want?
mbenatti commented
In my example I have this list:
[[number: "1102", sell_price: "3131121", area: "244.32", total_area: "304.03"],
[number: "1101", sell_price: "3582312", area: "244.32", total_area: "304.03"]]
Where key represents the Header and the value represents the Row cell
I want to transform in .xlsx like that:
number | sell_price | area | total_area
1101 | 3582312 | 244.32 | 304.03
1102 | 3131121 | 244.32 | 304.03
unti1x commented
headers = data
|> List.first
|> Keyword.keys
|> Enum.map(&Atom.to_string/1)
values = Enum.map data, &Keyword.values/1
sheet = %Sheet{rows: [headers] ++ values}