You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`xlsx_date_format_mappings` has been removed in favor of `column_data_styles` which provides more flexibility
58
58
59
-
## Configuring Styles
59
+
## Configuring Styles
60
60
61
61
Styles can be added to your worksheet header, column header row, body and column data from view attributes `header`, `column_header`, `body`, `column_data_styles`. Any arguments from [the OpenPyXL package](https://openpyxl.readthedocs.io/en/stable/styles.html) can be used for font, alignment, fill and border_side (border will always be all side of cell).
62
62
@@ -148,7 +148,7 @@ def get_header(self):
148
148
datetime_format ="%H:%M:%S %d.%m.%Y"
149
149
return {
150
150
'tab_title': 'MyReport', # title of tab/workbook
151
-
'use_header': True, # show the header_title
151
+
'use_header': True, # show the header_title
152
152
'header_title': 'Report from {} to {}'.format(
153
153
start_time.strftime(datetime_format),
154
154
end_time.strftime(datetime_format),
@@ -200,7 +200,7 @@ They can be set in the view as a property `sheet_view_options`:
200
200
```python
201
201
classMyExampleViewSet(serializers.Serializer):
202
202
sheet_view_options = {
203
-
'rightToLeft': True,
203
+
'rightToLeft': True,
204
204
'showGridLines': False
205
205
}
206
206
```
@@ -209,18 +209,18 @@ or using method `get_sheet_view_options`:
209
209
210
210
```python
211
211
classMyExampleViewSet(serializers.Serializer):
212
-
212
+
213
213
defget_sheet_view_options(self):
214
214
return {
215
-
'rightToLeft': True,
215
+
'rightToLeft': True,
216
216
'showGridLines': False
217
217
}
218
218
```
219
219
## Controlling XLSX headers and values
220
220
221
221
### Use Serializer Field labels as header names
222
222
223
-
By default, headers will use the same 'names' as they are returned by the API. This can be changed by setting `xlsx_use_labels = True` inside your API View.
223
+
By default, headers will use the same 'names' as they are returned by the API. This can be changed by setting `xlsx_use_labels = True` inside your API View.
224
224
225
225
Instead of using the field names, the export will use the labels as they are defined inside your Serializer. A serializer field defined as `title = serializers.CharField(label=_("Some title"))` would return `Some title` instead of `title`, also supporting translations. If no label is set, it will fall back to using `title`.
0 commit comments