Skip to content

Commit 6626a97

Browse files
committed
Use black border if styled but color unspecified
1 parent 16258a9 commit 6626a97

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

pandas/io/formats/excel.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,21 @@ def _get_is_wrap_text(self, props: Mapping[str, str]) -> bool | None:
243243
def build_border(
244244
self, props: Mapping[str, str]
245245
) -> dict[str, dict[str, str | None]]:
246-
return {
247-
side: {
248-
"style": self._border_style(
249-
props.get(f"border-{side}-style"),
250-
props.get(f"border-{side}-width"),
251-
self.color_to_excel(props.get(f"border-{side}-color")),
252-
),
253-
"color": self.color_to_excel(props.get(f"border-{side}-color")),
246+
border_dict = {}
247+
for side in ["top", "right", "bottom", "left"]:
248+
style = self._border_style(
249+
props.get(f"border-{side}-style"),
250+
props.get(f"border-{side}-width"),
251+
self.color_to_excel(props.get(f"border-{side}-color")),
252+
)
253+
color = self.color_to_excel(props.get(f"border-{side}-color"))
254+
if style and style != "none" and color is None:
255+
color = self.color_to_excel("black")
256+
border_dict[side] = {
257+
"style": style,
258+
"color": color
254259
}
255-
for side in ["top", "right", "bottom", "left"]
256-
}
260+
return border_dict
257261

258262
def _border_style(self, style: str | None, width: str | None, color: str | None):
259263
# convert styles and widths to openxml, one of:

0 commit comments

Comments
 (0)