You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [ ] a bug report
- [x] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
If a spreadsheet has worksheets with a code names, then code names are respected and written to the generated file.
What is the current behavior?
Code names are not written to the generated file unless the spreadsheet has any macros.
What are the steps to reproduce?
<?phprequire__DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$spreadsheet->getActiveSheet()->setCodeName($expected = 'foo');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save($path = tempnam(sys_get_temp_dir(), 'example'));
$reader = PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$actual = $reader
->load($path)
->getActiveSheet()
->getCodeName()
;
if ($actual !== $expected) {
printf("Expected code name of active sheet to be 'foo', got '%s'.\n", $actual);
exit(1);
}
Which versions of PhpSpreadsheet and PHP are affected?
PHP: any version
PhpSpreadsheet: 1.10.1
Dear maintainer, would you consider always setting the code name regardless of whether macros exist in the spreadsheet or not? Currently this block controls whether or not to add code names to the generated file. I would propose removing the if-guard so that code names would always be written.
The specific use case I have is to provide the user with a template, which they could fill and then submit back to the same system. Using code names would make the template more flexible and resistant to changes to worksheet names (i.e. downloading a template in one locale & submitting it back in a different one).
Would you accept such a contribution, if I made a PR? Any implementation gotcha-s (i.e. other formats etc.)?
Thanks,
Kristen
The text was updated successfully, but these errors were encountered:
kgilden
added a commit
to kgilden/PhpSpreadsheet
that referenced
this issue
Feb 11, 2020
Previously the XLSX writer would only add code names to worksheets, if
the spreadsheet had any macros. However, sometimes code names are useful
on their own.
Previously the XLSX writer would only add code names to worksheets, if
the spreadsheet had any macros. However, sometimes code names are useful
on their own.
Ok, discard that. Looks like most tools out in the wild don't respect code names either so there's really no point to encourage using code names for this use case. Closing the PR.
This is:
What is the expected behavior?
If a spreadsheet has worksheets with a code names, then code names are respected and written to the generated file.
What is the current behavior?
Code names are not written to the generated file unless the spreadsheet has any macros.
What are the steps to reproduce?
Which versions of PhpSpreadsheet and PHP are affected?
Dear maintainer, would you consider always setting the code name regardless of whether macros exist in the spreadsheet or not? Currently this block controls whether or not to add code names to the generated file. I would propose removing the if-guard so that code names would always be written.
The specific use case I have is to provide the user with a template, which they could fill and then submit back to the same system. Using code names would make the template more flexible and resistant to changes to worksheet names (i.e. downloading a template in one locale & submitting it back in a different one).
Would you accept such a contribution, if I made a PR? Any implementation gotcha-s (i.e. other formats etc.)?
Thanks,
Kristen
The text was updated successfully, but these errors were encountered: