how do you handle Decimal Data?
CharlesOkwuagwu opened this issue · 3 comments
CharlesOkwuagwu commented
Hi, great work on this library.
Please i'm using this to create excel files from a database.
Some of my data contains decimals (via the Elixir Decimal library, e.g. #Decimal<100.25>)
This error comes up:
ERR: %CaseClauseError{term: #Decimal<100.0>}
(elixlsx) lib/elixlsx/xml_templates.ex:163: Elixlsx.XMLTemplates.get_content_type_value/2
(elixlsx) lib/elixlsx/xml_templates.ex:197: anonymous fn/3 in Elixlsx.XMLTemplates.xl_sheet_cols/3
(elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
(elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
(elixlsx) lib/elixlsx/xml_templates.ex:185: Elixlsx.XMLTemplates.xl_sheet_cols/3
(elixlsx) lib/elixlsx/xml_templates.ex:258: anonymous fn/3 in Elixlsx.XMLTemplates.xl_sheet_rows/3
Please how may we use the Decimal type with elixlsx
Thanks.
unti1x commented
Hello. Elixir works only with primitive types, such as string
or float
. So, you have to convert value with Decimal.to_float/1 before using it in sheet.
CharlesOkwuagwu commented
Thanks. I have submitted a PR for that.