Skip to content

Commit 65d8361

Browse files
committed
fix #713 : fixed maximum length of sheet names (31 characters instead of 30 characters) when adding a new sheet to an Excel Workbook
1 parent fccd8a2 commit 65d8361

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/source/changes/version_0_30.rst.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,6 @@ Fixes
178178
-----
179179

180180
* fixed LArray.divnot0 being slow when the divisor has many axes and many zeros (closes :issue:`705`).
181+
182+
* fixed maximum length of sheet names (31 characters instead of 30 characters) when adding a new sheet
183+
to an Excel Workbook (closes :issue:`713`).

larray/core/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def _translate_sheet_name(sheet_name):
657657
sheet_name = str(_to_tick(sheet_name))
658658
if isinstance(sheet_name, basestring):
659659
sheet_name = _sheet_name_pattern.sub('_', sheet_name)
660-
if len(sheet_name) > 30:
660+
if len(sheet_name) > 31:
661661
raise ValueError("Sheet names cannot exceed 31 characters")
662662
return sheet_name
663663

larray/tests/test_array.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,6 +3870,12 @@ def test_to_excel_xlwings(tmpdir):
38703870
assert sheet_names == sorted(['a0', 'a1', 'a2', 'a3', 'c0,c2', 'c0__2', 'even',
38713871
'_name_with_special___char_'])
38723872

3873+
# sheet name of 31 characters (= maximum authorized length)
3874+
a3.to_excel(fpath, "sheetname_of_exactly_31_chars__", engine='xlwings')
3875+
# sheet name longer than 31 characters
3876+
with pytest.raises(ValueError, message="Sheet names cannot exceed 31 characters"):
3877+
a3.to_excel(fpath, "sheetname_longer_than_31_characters", engine='xlwings')
3878+
38733879

38743880
def test_as_table():
38753881
res = list(ndtest(3).as_table(wide=False, value_name='data'))

0 commit comments

Comments
 (0)