Skip to content

Commit e14a9bd

Browse files
authored
ENH: Report how far off the formatting is (#57667)
1 parent 69f03a3 commit e14a9bd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pandas/io/excel/_base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,8 @@ def _value_with_fmt(
13271327
# xref https://support.microsoft.com/en-au/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
13281328
if len(val) > 32767:
13291329
warnings.warn(
1330-
"Cell contents too long, truncated to 32767 characters",
1330+
f"Cell contents too long ({len(val)}), "
1331+
"truncated to 32767 characters",
13311332
UserWarning,
13321333
stacklevel=find_stack_level(),
13331334
)

pandas/tests/io/excel/test_writers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def test_to_excel_empty_frame(self, engine, tmp_excel):
13901390
def test_to_excel_raising_warning_when_cell_character_exceed_limit(self):
13911391
# GH#56954
13921392
df = DataFrame({"A": ["a" * 32768]})
1393-
msg = "Cell contents too long, truncated to 32767 characters"
1393+
msg = r"Cell contents too long \(32768\), truncated to 32767 characters"
13941394
with tm.assert_produces_warning(
13951395
UserWarning, match=msg, raise_on_extra_warnings=False
13961396
):

0 commit comments

Comments
 (0)