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

Is Column Format Supported? #4

Closed kwatog closed 2 years ago

kwatog commented 6 years ago

does it support formatting for specific columns? Example, left align for text columns and right align for numbers.

FlipperPA commented 5 years ago

It currently does not, as we are limited by the data passed to the renderer from Django REST Framework. I'm open to ideas, however. We may be able to pass styles to OpenPyXL.

Renegade9 commented 5 years ago

This XLSX rendering solution is great!

I also have a formatting issue. All my numerical columns are being interpreted as text, causing Excel to flag them as "Number Stored as Text" with a warning.

I'd like to format my cells, and I can follow an approach like setting styles as appropriate in my get_column_header() or get_body() methods (e.g. based on known or examined data formats, or based on column naming conventions). However, I cannot figure out what OpenPyXL styles to set to make this happen. number_format does not appear to work. Any suggestions?

FlipperPA commented 5 years ago

@Tigven did the work on customizing styles, and he may have more information... or thoughts on how it can be accomplished.

Renegade9 commented 5 years ago

@FlipperPA we were using an older version, so we upgraded to 0.3.2 (from 0.3.0) and that happened to also fix the problem we were having of numeric fields being interpreted as text fields, so thanks to whoever fixed this!

FlipperPA commented 5 years ago

@Renegade9 Fantastic to hear! Team work makes the dream work. :)

ProgrammingJoe commented 5 years ago

Hello @FlipperPA has there been any movement on adding styles to specific columns?

FlipperPA commented 5 years ago

@ProgrammingJoe There hasn't, as my organization doesn't have a need for the feature (yet) so I haven't had time to look into it. I've added a note to the README about how we prioritize feature requests.

FlipperPA commented 2 years ago

@ProgrammingJoe @kwatog @Renegade9 Hey folks! This is now supported in version 2.0.0.