Skip to content

Unnecessarily enforces maximum of 31 characters in sheet titles #176

@MikkelPaulson

Description

@MikkelPaulson

This is:

Summary

XLSX files (at the very least) support sheet titles over 31 characters, but PhpSpreadsheet enforces a 31-character limit regardless of file format. This would be annoying if it only affected sheet creation, but the validation code is also run on load. This means that PhpSpreadsheet is unable to load any valid XLSX file (or file of any other format) containing a sheet with a name over 32 characters.

What is the expected behavior?

A worksheet title containing 32 characters is set correctly. An exception should only be thrown when saving to a format that doesn't support longer titles.

What is the current behavior?

An exception is thrown with the message "Maximum 31 characters allowed in sheet code name.".

What are the steps to reproduce?

(Shows creating a new file, but the same behaviour is encountered when loading an existing file with a sheet title over 31 chars.)

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getSheet();
$sheet->setTitle('ten chars ten chars ten chars +2');

Which versions of PhpSpreadsheet and PHP are affected?

PHPExcel 1.8, PhpSpreadsheet develop

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions