Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a

- Slightly better support for escaped characters in Xlsx Reader/Writer. [Discussion #4724](https://github.com/PHPOffice/PhpSpreadsheet/discussions/4724) [PR #4726](https://github.com/PHPOffice/PhpSpreadsheet/pull/4726)
- CODE/UNICODE and CHAR/UNICHAR. [PR #4727](https://github.com/PHPOffice/PhpSpreadsheet/pull/4727)
- Minor changes to TextGrid. [PR #4735](https://github.com/PHPOffice/PhpSpreadsheet/pull/4735)

## 2025-11-24 - 5.3.0

Expand Down
2 changes: 1 addition & 1 deletion samples/Autofilter/10_Autofilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
['2011', 'Q4', 'Italy', 335],
];
$spreadsheet->getActiveSheet()->fromArray($dataArray, null, 'A2');
$helper->displayGrid($spreadsheet->getActiveSheet()->toArray(null, false, false, true));
$helper->displayGrid($spreadsheet->getActiveSheet()->toArray(null, false, false, true), true);

// Set title row bold
$helper->log('Set title row bold');
Expand Down
6 changes: 3 additions & 3 deletions samples/Autofilter/10_Autofilter_selection_1.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
// Create the worksheet
$helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year')
->setCellValue('B1', 'Financial Period')
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Year')
->setCellValue('B1', 'Period')
->setCellValue('C1', 'Country')
->setCellValue('D1', 'Date')
->setCellValue('E1', 'Sales Value')
->setCellValue('E1', 'Sales')
->setCellValue('F1', 'Expenditure');
$dateTime = new DateTime();
$startYear = $endYear = $currentYear = (int) $dateTime->format('Y');
Expand Down
6 changes: 3 additions & 3 deletions samples/Autofilter/10_Autofilter_selection_2.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
// Create the worksheet
$helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year')
->setCellValue('B1', 'Financial Period')
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Year')
->setCellValue('B1', 'Period')
->setCellValue('C1', 'Country')
->setCellValue('D1', 'Date')
->setCellValue('E1', 'Sales Value')
->setCellValue('E1', 'Sales')
->setCellValue('F1', 'Expenditure');
$dateTime = new DateTime();
$startYear = $endYear = $currentYear = (int) $dateTime->format('Y');
Expand Down
6 changes: 3 additions & 3 deletions samples/Autofilter/10_Autofilter_selection_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
// Create the worksheet
$helper->log('Add data');
$spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Financial Year')
->setCellValue('B1', 'Financial Period')
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Year')
->setCellValue('B1', 'Period')
->setCellValue('C1', 'Country')
->setCellValue('D1', 'Date')
->setCellValue('E1', 'Sales Value')
->setCellValue('E1', 'Sales')
->setCellValue('F1', 'Expenditure');
$dateTime = new DateTime();
$startYear = $endYear = $currentYear = (int) $dateTime->format('Y');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DAVERAGE.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The Average age of all Apple and Pear trees in the orchard');
$worksheet->setCellValue('B13', '=DAVERAGE(A4:E10,3,A1:A3)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
2 changes: 1 addition & 1 deletion samples/Database/DCOUNT.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
2 changes: 1 addition & 1 deletion samples/Database/DCOUNTA.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DGET.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The height of the Apple tree (will return an Excel error, because there is more than one apple tree)');
$worksheet->setCellValue('B13', '=DGET(A4:E10,"Height",A1:A2)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DMAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The Oldest apple tree in the orchard');
$worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DMIN.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The Youngest apple tree in the orchard');
$worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
2 changes: 1 addition & 1 deletion samples/Database/DPRODUCT.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DSTDEV.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The estimated standard deviation in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DSTDEV(A4:E10,2,A1:A3)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DSTDEVP.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The standard deviation in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DSUM.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'Total profit from apple trees with a height between 10 and 16 feet, and all pear trees');
$worksheet->setCellValue('B13', '=DSUM(A4:E10,"Profit",A1:F3)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DVAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The estimated variance in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
4 changes: 3 additions & 1 deletion samples/Database/DVARP.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

$worksheet->setCellValue('A13', 'The variance in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)');
$worksheet->getStyle('E5:E10')->getNumberFormat()
->setFormatCode('0.00');

$helper->log('Database');

$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
$helper->displayGrid($databaseData);
$helper->displayGrid($databaseData, true);

// Test the formulae
$helper->log('Criteria');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ public function readCell(string $columnAddress, int $row, string $worksheetName
$reader->setReadFilter($chunkFilter);
// Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
$sheet = $spreadsheet->getActiveSheet();

// Do some processing here

$activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension();
$sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData);
$activeRange = $sheet->calculateWorksheetDataDimension();
$sheet->getStyle($activeRange)->getNumberFormat()
->setFormatCode('0.000');
$sheetData = $sheet->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData, true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ public function readCell(string $columnAddress, int $row, string $worksheetName
$chunkFilter->setRows($startRow, $chunkSize);
// Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object
$spreadsheet = $reader->load($inputFileName);
$sheet = $spreadsheet->getActiveSheet();

// Do some processing here

$activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension();
$sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData);
$activeRange = $sheet->calculateWorksheetDataDimension();
$sheet->getStyle($activeRange)->getNumberFormat()
->setFormatCode('0.000');
$sheetData = $sheet->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData, true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
$helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . '</b>');
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
$sheet = $spreadsheet->getActiveSheet();

$activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension();
$sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData);
$activeRange = $sheet->calculateWorksheetDataDimension();
$sheet->getStyle($activeRange)->getNumberFormat()
->setFormatCode('0.000');
$sheetData = $sheet->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData, true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ public function readCell(string $columnAddress, int $row, string $worksheetName
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
$helper->log('<b>Worksheet #' . $sheetIndex . ' -> ' . $loadedSheetName . '</b>');
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
$sheet = $spreadsheet->getActiveSheet();

$activeRange = $spreadsheet->getActiveSheet()->calculateWorksheetDataDimension();
$sheetData = $spreadsheet->getActiveSheet()->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData);
$activeRange = $sheet->calculateWorksheetDataDimension();
$sheet->getStyle($activeRange)->getNumberFormat()
->setFormatCode('0.000');
$sheetData = $sheet->rangeToArray($activeRange, null, true, true, true);
$helper->displayGrid($sheetData, true);
}
2 changes: 1 addition & 1 deletion samples/Table/02_Table_Total.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

$helper->log('Calculate Structured References');

$helper->displayGrid($spreadsheet->getActiveSheet()->toArray(null, true, true, true));
$helper->displayGrid($spreadsheet->getActiveSheet()->toArray(null, true, true, true), true);

// Save
$helper->write($spreadsheet, __FILE__, ['Xlsx']);
2 changes: 1 addition & 1 deletion samples/Table/04_Column_Formula_with_Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

$helper->log('Calculate Structured References');

$helper->displayGrid($spreadsheet->getActiveSheet()->toArray(null, true, true, true));
$helper->displayGrid($spreadsheet->getActiveSheet()->toArray(null, true, true, true), true);

// Save
$helper->write($spreadsheet, __FILE__, ['Xlsx']);
5 changes: 4 additions & 1 deletion src/PhpSpreadsheet/Helper/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,12 @@ public function titles(string $category, string $functionName, ?string $descript
}

/** @param mixed[][] $matrix */
public function displayGrid(array $matrix): void
public function displayGrid(array $matrix, ?bool $numbersRight = null): void
{
$renderer = new TextGrid($matrix, $this->isCli());
if ($numbersRight !== null) {
$renderer->setNumbersRight($numbersRight);
}
echo $renderer->render();
}

Expand Down
Loading