xou/elixlsx

Is it possible to set the formatting of a column as date?

Opened this issue · 3 comments

I saw cell formatting is possible. But is it possible to format a column

Yes that is possible.
For some examples, see the example.exs.

For format your column as date use the :datetime, :yyyymmdd or :num_format option.

Sheet.set_cell(sheet, "A2", {{2015, 11, 30}, {21, 20, 38}}, datetime: true)
Sheet.set_cell(sheet, "A4", 1448882362, yyyymmdd: true)
Sheet.set_cell(sheet, "F1", {:formula, "NOW()"}, num_format: "yyyy-mm-dd hh:MM:ss")

That is formatting cell one by one. Is it possible to format the column, something like
Sheet.set_column(sheet, "A", {{2015, 11, 30}, {21, 20, 38}}, datetime: true), which formats the column A as date

Currently the only information able to be stored for columns appears to be column_width. Instead of storing an integer for col_width, I think that a map should be stored %{width: integer} for each column. Additional column information could then be included e.g. fill, number format etc. The xml generation functions would need to be updated to interpret the additional fields and output the correct xml. I intend to work on this.