Skip to content

Adding worksheet title does not check for duplicate names in a case insensitive way #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 3 tasks
ant-g opened this issue Jun 8, 2018 · 2 comments
Closed
1 of 3 tasks

Comments

@ant-g
Copy link

ant-g commented Jun 8, 2018

This is:

What is the expected behavior?

Set worksheet title the same as an existing worksheet title and a title is added with a count number at the end

What is the current behavior?

When adding two sheets of the same name and same case feature works
But when different case is used, the sheet titles are not recognised as the same (but Excel does and complains about it)

What are the steps to reproduce?

<?php

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$index=1;
$spreadsheet->createSheet();
$sheet = $excel->setActiveSheetIndex($index);
$sheet->setTitle('My Same Sheet');
$index++;
$spreadsheet->createSheet();
$sheet = $excel->setActiveSheetIndex($index);
$sheet->setTitle('My Same Sheet');
$index++;
$spreadsheet->createSheet();
$sheet = $excel->setActiveSheetIndex($index);
$sheet->setTitle('My Different Sheet');
$index++;
$spreadsheet->createSheet();
$sheet = $excel->setActiveSheetIndex($index);
$sheet->setTitle('My different Sheet');

// Output sheet, all works fine but when opening in Excel needs to 'Correct data', last sheet will become named 'Recovered_Sheet1'

To be honest I've not run this specific test but it mimics what my code is doing.

I have fixed it by changing PHPExcel->getSheetByName() to use:

if (strcasecmp($this->workSheetCollection[$i]->getTitle(),$pName)===0) {
    return $this->workSheetCollection[$i];
}

Which versions of PhpSpreadsheet and PHP are affected?

PHP 7
PhpSpreadsheet latest

@stale
Copy link

stale bot commented Aug 11, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Aug 11, 2018
@stale stale bot closed this as completed Aug 18, 2018
@oleibman
Copy link
Collaborator

Fixed by PR #3791 in November 2023.

@oleibman oleibman removed the stale label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants