Skip to content

Commit

Permalink
ENH: Report how far off the formatting is (#57667)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Feb 28, 2024
1 parent 69f03a3 commit e14a9bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@ def _value_with_fmt(
# xref https://support.microsoft.com/en-au/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
if len(val) > 32767:
warnings.warn(
"Cell contents too long, truncated to 32767 characters",
f"Cell contents too long ({len(val)}), "
"truncated to 32767 characters",
UserWarning,
stacklevel=find_stack_level(),
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def test_to_excel_empty_frame(self, engine, tmp_excel):
def test_to_excel_raising_warning_when_cell_character_exceed_limit(self):
# GH#56954
df = DataFrame({"A": ["a" * 32768]})
msg = "Cell contents too long, truncated to 32767 characters"
msg = r"Cell contents too long \(32768\), truncated to 32767 characters"
with tm.assert_produces_warning(
UserWarning, match=msg, raise_on_extra_warnings=False
):
Expand Down

0 comments on commit e14a9bd

Please sign in to comment.