Skip to content

Commit ce5f91e

Browse files
authored
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.
1 parent bd2e7b6 commit ce5f91e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

samples/Basic/39_Dropdown.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function transpose($value)
4646
new NamedRange(
4747
$continent,
4848
$spreadsheet->getActiveSheet(),
49-
$column . '1:' . $column . $countryCount
49+
'$' . $column . '$1:$' . $column . '$' . $countryCount
5050
)
5151
);
5252
$spreadsheet->getActiveSheet()
@@ -68,7 +68,7 @@ function transpose($value)
6868
new NamedRange(
6969
'Continents',
7070
$spreadsheet->getActiveSheet(),
71-
$continentColumn . '1:' . $continentColumn . count($continents)
71+
'$' . $continentColumn . '$1:$' . $continentColumn . '$' . count($continents)
7272
)
7373
);
7474

@@ -126,4 +126,5 @@ function transpose($value)
126126
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(30);
127127

128128
// Save
129-
$helper->write($spreadsheet, __FILE__);
129+
$helper->log('Not writing to Xls - formulae with defined names not yet supported');
130+
$helper->write($spreadsheet, __FILE__, ['Xlsx']);

0 commit comments

Comments
 (0)