Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
df = pd.DataFrame({"a": [1]})
styler = df.style.applymap(lambda x: "border-style: hair; border-color: black")
styler.to_excel(r"test_border.xlsx", engine="xlsxwriter")
Issue Description
The CSSToExcelConverter._border_style
function does not return any value (i.e., None) when the style string is not recognized. However, "hair" should be a recognized style string in xlsxwriter, corresponding to border index "7". This leads to a crash in xlsxwriter
. Moreover, there is no path to actually return the "hair" style for any engine.
Expected Behavior
Use of border-style: hair
will export a spreadsheet with the correct formatting.
Installed Versions
Comment From: tehunter
take
Comment From: rhshadrach
Thanks for the report @tehunter! Your versions indicate 1.5.0rc; do you know if this bug exists in previous versions?
Comment From: tehunter
I know that previous versions also had an inability to use the "hair" style. I'm unsure at the moment if it led to the same error. I think it probably gave the same error identified here and in #45312.
In addition to adding support for the "hair" style, I think we probably need to have a "soft fail" for unrecognized/unimplemented border combinations. I'll work on adding both in a PR.
Comment From: rhshadrach
However, "hair" should be a recognized style string in xlsxwriter, corresponding to border index "1"
Why not index 7? Does weight 0 mean that there is no visible border for index 7?
Comment From: tehunter
Yes, thanks for confirming. I misread the table; "hair" corresponds to index 7.
Comment From: tehunter
Submitted a PR: #48660
Comment From: minhson1411
hello bạn ơi!