Feature request: Allow identifying formats by name
See original GitHub issueToday, when dealing with complex an multiple formats, I use the following piece of code to be able to retrieve them at the time to write data :
def register_formats(wb, d):
return {k: wb.add_format(v) if v is not None else v for k, v in d.items()}
#my_formats d parameter simplified for readability sake
my_formats = register_formats(workbook, {
'error': {'bg_color': '#cc0000'},
'warning': {'bg_color': '#ffff00'},
'ok': None})
# Much farther in the program ...
ws = wb.add_worksheet()
ws.write(0,0,"text", my_formats['error'])
but then one has to pass this my_format dictionary around.
I suggest to extend the workbook interface with an optional ref parameter, and then in the write functions be able to give the reference of the format rather than the format itself. It would result in something like :
wb.add_format({'bg_color': '#cc0000'}, ref="error")
#####
ws.write(0,0,"text", format_ref="error")
I can propose an implementation if that helps.
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (12 by maintainers)
Top Results From Across the Web
How To Manage Feature Requests [Template included]
This guide will teach you everything about feature requests – how to process them, manage them, respond to them, prioritize them – so...
Read more >Feature Requests: What are they and how to manage them
Feature requests are a form of product feedback you may frequently encounter as a SaaS product manager. They typically come in the form...
Read more >Feature Request Template: How to Collect User Feedback ...
Looking for the best feature request templates? Here's how to collect feedback with examples from the best SaaS companies.
Read more >Feature request tracking: Guide, tools & best practices - Beamer
Feature requests are feedback forms that customers can fill out to ask for new features or suggest improvements to existing ones.
Read more >What Is a Feature Request? Definition and Examples - Airfocus
A feature request is a comment, message, or ask from a user to implement a specific feature into your product. Feature requests can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m going to leave the discussion of #111 to that thread.
For this feature a straight forward interface (and implemention) would be to add a user definable
name
field to theformat
object that would allow you to do this:Would that meet the needs of the 1+ers?
There are a couple of internal gottas that I would have to workaround but it would be doable.
The second part about adding a
ref
parameter to all thewrite_*()
functions, I’m not keen on. It would just complicate the interface, docs and testing.P.S.
get_format()
would probably be a better method name and as an asideget_worksheet_by_name()
should probably been calledget_worksheet()
(the_by_name()
part is implied and a little long).I’m going through some older feature requests into XlsxWriter and closing out ones that I am unlikely to work on in the near future. This is one of them unfortunately.