django-commons / drf-excel

An XLSX spreadsheet renderer for Django REST Framework.
BSD 3-Clause "New" or "Revised" License
217 stars 40 forks source link

Number, date, boolean etc. formatting #51

Closed rptmat57 closed 2 years ago

rptmat57 commented 2 years ago

I noticed everything is formatted as a string, mostly due to the sanitization function. I started looking into it and I think I found a way to customize cell formats etc.

This is probably similar to #4 and I think also overlaps a bit of #49 I also think this would provide the basis for dealing with #44

My idea here is to create XLSXField classes for each type, map it from drf types and value types, and then deal with the formatting of each type directly in the XLSXField class.

For example XLSXNumberField would map from drf IntegerField, FloatField or DecimalField, and also from values of type int, float or decimal.

I will be updating #50 for this. Hope this is okay