Fix Sample39 (#2664)

Sample39 was not adjusted when Defined Name support was changed to include both relative and absolute addresses. As a result, the Xlsx output is currently incorrect. The Xls output is in even worse shape, since PhpSpreadsheet 'Cannot yet write formulae with defined names to Xls' (see Writer/Xls/Parser.php). (Working around that restriction was the reason for my first contribution to this project.) The sample is changed to define its named ranges properly, and to produce only Xlsx output.
This commit is contained in:
oleibman 2022-03-09 18:55:31 -08:00 committed by GitHub
parent bd2e7b64a6
commit ce5f91e6a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -46,7 +46,7 @@ foreach ($continents as $key => $filename) {
new NamedRange( new NamedRange(
$continent, $continent,
$spreadsheet->getActiveSheet(), $spreadsheet->getActiveSheet(),
$column . '1:' . $column . $countryCount '$' . $column . '$1:$' . $column . '$' . $countryCount
) )
); );
$spreadsheet->getActiveSheet() $spreadsheet->getActiveSheet()
@ -68,7 +68,7 @@ $spreadsheet->addNamedRange(
new NamedRange( new NamedRange(
'Continents', 'Continents',
$spreadsheet->getActiveSheet(), $spreadsheet->getActiveSheet(),
$continentColumn . '1:' . $continentColumn . count($continents) '$' . $continentColumn . '$1:$' . $continentColumn . '$' . count($continents)
) )
); );
@ -126,4 +126,5 @@ $spreadsheet->getActiveSheet()->getColumnDimension('A')->setWidth(12);
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(30); $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(30);
// Save // Save
$helper->write($spreadsheet, __FILE__); $helper->log('Not writing to Xls - formulae with defined names not yet supported');
$helper->write($spreadsheet, __FILE__, ['Xlsx']);