Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/XLSX-Image-Background-In-Comment…
Browse files Browse the repository at this point in the history
…s' into XLSX-Image-Background-In-Comments
  • Loading branch information
Burkov Sergey committed Dec 13, 2021
2 parents 93782f0 + c64aa84 commit 77414af
Show file tree
Hide file tree
Showing 40 changed files with 912 additions and 65 deletions.
24 changes: 24 additions & 0 deletions docs/topics/autofilters.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ $spreadsheet->getActiveSheet()->setAutoFilter(

This enables filtering, but does not actually apply any filters.

After setting the range, you can change it so that the end row is the
last row used on the worksheet:

```php
$spreadsheet->getActiveSheet()->getAutoFilter()->setRangeToMaxRow();
```

## Autofilter Expressions

PHPEXcel 1.7.8 introduced the ability to actually create, read and write
Expand Down Expand Up @@ -503,6 +510,23 @@ $autoFilter->showHideRows();
This will set all rows that match the filter criteria to visible, while
hiding all other rows within the autofilter area.

Excel allows you to explicitly hide a row after applying a filter even
if the row wasn't hidden by the filter. However, if a row is hidden *before*
applying the filter, and the filter is applied, the row will no longer be hidden.
This can make a difference during PhpSpreadsheet save, since PhpSpreadsheet
will apply the filter during save if it hasn't been previously applied,
or if the filter criteria have changed since it was last applied.
Note that an autofilter read in from an existing spreadsheet is assumed to have been applied.
Also note that changing the data in the columns being filtered
does not result in reevaluation in either Excel or PhpSpreadsheet.
If you wish to re-apply all filters in the spreadsheet
(possibly just before save):
```php
$spreadsheet->reevaluateAutoFilters(false);
```
You can specify `true` rather than `false` to adjust the filter ranges
on each sheet so that they end at the last row used on the sheet.

### Displaying Filtered Rows

Simply looping through the rows in an autofilter area will still access
Expand Down
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5190,11 +5190,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Shared/StringHelper.php

-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:countCharacters\\(\\) should return int but returns int\\|false\\.$#"
count: 1
path: src/PhpSpreadsheet/Shared/StringHelper.php

-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:formatNumber\\(\\) should return string but returns array\\|string\\.$#"
count: 1
Expand Down Expand Up @@ -6050,11 +6045,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Worksheet/Column.php

-
message: "#^Cannot use array destructuring on array\\|false\\.$#"
count: 2
path: src/PhpSpreadsheet/Worksheet/Drawing.php

-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Drawing\\\\Shadow\\:\\:\\$color \\(PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Color\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Color\\|null\\.$#"
count: 1
Expand Down Expand Up @@ -6970,11 +6960,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php

-
message: "#^Parameter \\#1 \\$ascii of function chr expects int, float given\\.$#"
count: 3
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php

-
message: "#^Parameter \\#1 \\$bitmap of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\Worksheet\\:\\:processBitmap\\(\\) expects string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -7640,11 +7625,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php

-
message: "#^Parameter \\#3 \\$namespace of method XMLWriter\\:\\:startElementNs\\(\\) expects string, null given\\.$#"
count: 8
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php

-
message: "#^Parameter \\#3 \\$stringTable of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Worksheet\\:\\:writeSheetData\\(\\) expects array\\<string\\>, array\\<string\\>\\|null given\\.$#"
count: 1
Expand Down
14 changes: 13 additions & 1 deletion phpstan-conditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$config = [];

if (PHP_VERSION_ID < 80000) {
// Change of signature in PHP 8.0
// GdImage not available before PHP8
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Method .* has invalid return type GdImage\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Shared/Drawing.php',
Expand Down Expand Up @@ -34,6 +34,18 @@
'path' => __DIR__ . '/src/PhpSpreadsheet/Writer/Xls/Worksheet.php',
'count' => 1,
];
// Erroneous analysis by Phpstan before PHP8 - 3rd parameter is nullable
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Parameter \\#3 \\$namespace of method XMLWriter\\:\\:startElementNs\\(\\) expects string, null given\\.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php',
'count' => 8,
];
// Erroneous analysis by Phpstan before PHP8 - mb_strlen does not return false
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:countCharacters\\(\\) should return int but returns int\\|false\\.$#',
'path' => __DIR__ . '/src/PhpSpreadsheet/Shared/StringHelper.php',
'count' => 1,
];
}

return $config;
7 changes: 7 additions & 0 deletions samples/Basic/05_UnexpectedCharacters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require __DIR__ . '/../Header.php';
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet2.php';

// Save
$helper->write($spreadsheet, __FILE__);
25 changes: 25 additions & 0 deletions samples/Pdf/21c_Pdf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;

require __DIR__ . '/../Header.php';

// Issue 2432 - styles were too large to fit in first Mpdf chunk, causing problems.
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$counter = 0;
$helper->log('Populate spreadsheet');
for ($row = 1; $row < 501; ++$row) {
$sheet->getCell("A$row")->setValue(++$counter);
// Add many styles by using slight variations of font color for each.
$sheet->getCell("A$row")->getStyle()->getFont()->getColor()->setRgb(sprintf('%06x', $counter));
$sheet->getCell("B$row")->setValue(++$counter);
$sheet->getCell("C$row")->setValue(++$counter);
}

$helper->log('Write to Mpdf');
$writer = new Mpdf($spreadsheet);
$filename = $helper->getFileName('21c_Pdf_mpdf.xlsx', 'pdf');
$writer->save($filename);
$helper->log("Saved $filename");
21 changes: 21 additions & 0 deletions samples/Reader/22_Reader_issue1767.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use PhpOffice\PhpSpreadsheet\IOFactory;

require __DIR__ . '/../Header.php';

$helper->log('Start');

$inputFileType = 'Xlsx';
$inputFileName = __DIR__ . '/sampleData/issue.1767.xlsx';

$helper->log('Loading file ' . $inputFileName . ' using IOFactory with a defined reader type of ' . $inputFileType);
$reader = IOFactory::createReader($inputFileType);
$helper->log('Loading all WorkSheets');
$reader->setLoadAllSheets();
$spreadsheet = $reader->load($inputFileName);

// Save
$helper->write($spreadsheet, __FILE__);

$helper->log('end');
Binary file added samples/Reader/sampleData/issue.1767.xlsx
Binary file not shown.
Binary file added samples/images/terms con#ditions.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/images/サンプル.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 77414af

Please sign in to comment.