Feature request: creating & applying cell styles and conditional formatting
I'm currently working on a large project in Julia, and a part of it is generating Excel reports. Ideally, these reports should mark anomalous results by different text & background colour such that it's easy to see at a glance if everything is as expected or where things went wrong. In particular, I'm looking for a way to do the following 3 things from Julia:
- create a cellstyle (font + text/background colour) for use in the generated Excel file;
- assign a cellstyle to a specific cell; and
- create a conditional formatting and apply it to specific cells.
Would it be possible to provide this functionality in a reasonably intuitive manner?
IS possible fomating cells ? How to add outside borders, to change format of numbers etc.. ? Paul
Currently there is a way, but it is not intuitive. I also don't know how to do it properly.
I'm planning adding this feature, but I'll have to do a major rewrite of this package. And unfortunately I have other priorities at this time.
I see, maybe pelse on sample , I can try more , ! Paul
Just leaving an example here - this API is obviously not ideal, but this works for setting the numeric format for a particular type
# at top level
const num_fmt = Ref{Int64}(0)
XLSX.default_cell_format(ws::XLSX.Worksheet, ::Float64) = XLSX.get_num_style_index(ws, num_fmt[])
# ... where file is actually written
outfile = XLSX.open_empty_template()
num_fmt[] = XLSX.styles_add_numFmt(outfile.workbook, "#,##0")
# output steps ...
XLSX.writexlsx("test.xlsx", outfile)
Would it be possible to take examples from how similar Python packages, such as openpyxl accomplish this? For example: https://openpyxl.readthedocs.io/en/stable/formatting.html
Just also adding to this conversation as such functionality does seem possible given what pandas has implemented: https://stackoverflow.com/questions/26265403/easiest-way-to-create-a-color-gradient-on-excel-using-python-pandas