Skip to content

Commit d881cf8

Browse files
authored
Merge branch 'master' into pr1449
2 parents a921d24 + 39fc513 commit d881cf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+908
-141
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2929
- Xlsx Writer Duplicate ContentTypes Entry for Background Image. [Issue #4179](https://github.com/PHPOffice/PhpSpreadsheet/issues/4179) [PR #4180](https://github.com/PHPOffice/PhpSpreadsheet/pull/4180)
3030
- Check strictNullComparison outside of loops. [PR #3347](https://github.com/PHPOffice/PhpSpreadsheet/pull/3347)
3131
- SUMIFS Does Not Require xlfn. [Issue #4182](https://github.com/PHPOffice/PhpSpreadsheet/issues/4182) [PR #4186](https://github.com/PHPOffice/PhpSpreadsheet/pull/4186)
32+
- Image Transparency/Opacity with Html Reader Changes. [Discussion #4117](https://github.com/PHPOffice/PhpSpreadsheet/discussions/4117) [PR #4142](https://github.com/PHPOffice/PhpSpreadsheet/pull/4142)
33+
- Option to Write Hyperlink Rather Than Label to Csv. [Issue #1412](https://github.com/PHPOffice/PhpSpreadsheet/issues/1412) [PR #4151](https://github.com/PHPOffice/PhpSpreadsheet/pull/4151)
34+
- Invalid Html Due to Cached Filesize. [Issue #1107](https://github.com/PHPOffice/PhpSpreadsheet/issues/1107) [PR #4184](https://github.com/PHPOffice/PhpSpreadsheet/pull/4184)
35+
- Add Dynamic valueBinder Property to Spreadsheet and Readers. [Issue #1395](https://github.com/PHPOffice/PhpSpreadsheet/issues/1395) [PR #4185](https://github.com/PHPOffice/PhpSpreadsheet/pull/4185)
3236

3337
## 2024-09-29 - 3.3.0 (no 3.0.\*, 3.1.\*, 3.2.\*)
3438

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/topics/Behind the Mask.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ If you wish to emulate the MS Excel behaviour, and automatically convert string
117117

118118
You can do this by changing the Value Binder, which will then apply every time you set a Cell value.
119119
```php
120+
// Old method using static property
120121
Cell::setValueBinder(new AdvancedValueBinder());
122+
// Preferred method using dynamic property since 3.4.0
123+
$spreadsheet->setValueBinder(new AdvancedValueBinder());
121124

122125
// Set Cell C21 using a formatted string value
123126
$worksheet->getCell('C20')->setValue('€ -12345.6789');

docs/topics/The Dating Game.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ $spreadsheet = new Spreadsheet();
257257
$worksheet = $spreadsheet->getActiveSheet();
258258
// Use the Advanced Value Binder so that our string date/time values will be automatically converted
259259
// to Excel serialized date/timestamps
260+
// Old method using static property
260261
Cell::setValueBinder(new AdvancedValueBinder());
262+
// Preferred method using dynamic property since 3.4.0
263+
$spreadsheet->setValueBinder(new AdvancedValueBinder());
261264

262265
// Write our data to the worksheet
263266
$worksheet->fromArray($projectHeading);

docs/topics/accessing-cells.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,15 @@ style information. The following example demonstrates how to set the
518518
value binder in PhpSpreadsheet:
519519

520520
```php
521-
/** PhpSpreadsheet */
522-
require_once 'src/Boostrap.php';
523-
524-
// Set value binder
521+
// Older method using static property
525522
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
526-
527523
// Create new Spreadsheet object
528524
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
529525

526+
// Preferred method using dynamic property since 3.4.0
527+
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
528+
$spreadsheet->setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
529+
530530
// ...
531531
// Add some data, resembling some different data types
532532
$spreadsheet->getActiveSheet()->setCellValue('A4', 'Percentage value:');
@@ -555,13 +555,20 @@ $stringValueBinder->setNumericConversion(false)
555555
->setBooleanConversion(false)
556556
->setNullConversion(false)
557557
->setFormulaConversion(false);
558+
// Older method using static property
558559
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( $stringValueBinder );
560+
// Preferred method using dynamic property since 3.4.0
561+
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
562+
$spreadsheet->setValueBinder( $stringValueBinder );
559563
```
560564

561565
You can override the current binder when setting individual cell values by specifying a different Binder to use in the Cell's `setValue()` or the Worksheet's `setCellValue()` methods.
562566
```php
563567
$spreadsheet = new Spreadsheet();
568+
// Old method using static property
564569
Cell::setValueBinder(new AdvancedValueBinder());
570+
// Preferred method using dynamic property since 3.4.0
571+
$spreadsheet->setValueBinder(new AdvancedValueBinder());
565572

566573
$value = '12.5%';
567574

docs/topics/reading-files.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,18 @@ So using a Value Binder allows a great deal more flexibility in the
755755
loader logic when reading unformatted text files.
756756

757757
```php
758-
/** Tell PhpSpreadsheet that we want to use the Advanced Value Binder **/
759-
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
760-
761758
$inputFileType = 'Csv';
762759
$inputFileName = './sampleData/example1.tsv';
763760

764761
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
765762
$reader->setDelimiter("\t");
763+
764+
/** Tell PhpSpreadsheet that we want to use the Advanced Value Binder **/
765+
// Old method using static property
766+
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
767+
// Preferred method using dynamic property since 3.4.0
768+
$reader::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
769+
766770
$spreadsheet = $reader->load($inputFileName);
767771
```
768772

@@ -774,7 +778,7 @@ Loading using a Value Binder applies to:
774778
Reader | Y/N |Reader | Y/N |Reader | Y/N
775779
----------|:---:|--------|:---:|--------------|:---:
776780
Xlsx | NO | Xls | NO | Xml | NO
777-
Ods | NO | SYLK | NO | Gnumeric | NO
781+
Ods | NO | SYLK | YES | Gnumeric | NO
778782
CSV | YES | HTML | YES
779783

780784
Note that you can also use the Binder to determine how PhpSpreadsheet identified datatypes for values when you set a cell value without explicitly setting a datatype.

docs/topics/recipes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ method that suits you the best. Here are some examples:
233233

234234
```php
235235
// MySQL-like timestamp '2008-12-31' or date string
236+
// Old method using static property
236237
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
238+
// Preferred method using dynamic property since 3.4.0
239+
$spreadsheet->setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
237240

238241
$spreadsheet->getActiveSheet()
239242
->setCellValue('D1', '2008-12-31');
@@ -599,7 +602,10 @@ when it sees a newline character in a string that you are inserting in a
599602
cell. Just like Microsoft Office Excel. Try this:
600603

601604
```php
605+
// Old method using static property
602606
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
607+
// Preferred method using dynamic property since 3.4.0
608+
$spreadsheet->setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
603609

604610
$spreadsheet->getActiveSheet()->getCell('A1')->setValue("hello\nworld");
605611
```

samples/Basic4/53_ImageOpacity.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
require __DIR__ . '/../Header.php';
4+
5+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6+
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
7+
8+
//var_dump(realpath(__DIR__ . '/../images/blue_square.png'));
9+
//exit();
10+
11+
$path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'images/blue_square.png';
12+
$spreadsheet = new Spreadsheet();
13+
$spreadsheet->getProperties()->setTitle('53_ImageOpacity');
14+
15+
$helper->log('Add image to spreadsheet 6 times with different opacities');
16+
$sheet = $spreadsheet->getActiveSheet();
17+
$sheet->setTitle('Squares different opacities');
18+
$sheet->setShowGridLines(false);
19+
20+
$drawing = new Drawing();
21+
$drawing->setName('Blue Square opacity not specified');
22+
$drawing->setPath($path);
23+
$drawing->setCoordinates('A1');
24+
$drawing->setCoordinates2('B5');
25+
$drawing->setWorksheet($sheet);
26+
27+
$drawing = new Drawing();
28+
$drawing->setName('Blue Square opacity 80%');
29+
$drawing->setPath($path);
30+
$drawing->setCoordinates('C1');
31+
$drawing->setCoordinates2('D5');
32+
$drawing->setOpacity(80000);
33+
$drawing->setWorksheet($sheet);
34+
35+
$drawing = new Drawing();
36+
$drawing->setName('Blue Square opacity 60%');
37+
$drawing->setPath($path);
38+
$drawing->setCoordinates('E1');
39+
$drawing->setCoordinates2('F5');
40+
$drawing->setOpacity(60000);
41+
$drawing->setWorksheet($sheet);
42+
43+
$drawing = new Drawing();
44+
$drawing->setName('Blue Square opacity 40%');
45+
$drawing->setPath($path);
46+
$drawing->setCoordinates('A8');
47+
$drawing->setCoordinates2('B12');
48+
$drawing->setOpacity(40000);
49+
$drawing->setWorksheet($sheet);
50+
51+
$drawing = new Drawing();
52+
$drawing->setName('Blue Square opacity 20%');
53+
$drawing->setPath($path);
54+
$drawing->setCoordinates('C8');
55+
$drawing->setCoordinates2('D12');
56+
$drawing->setOpacity(20000);
57+
$drawing->setWorksheet($sheet);
58+
59+
$drawing = new Drawing();
60+
$drawing->setName('Blue Square opacity 0%');
61+
$drawing->setPath($path);
62+
$drawing->setCoordinates('E8');
63+
$drawing->setCoordinates2('F12');
64+
$drawing->setOpacity(0);
65+
$drawing->setWorksheet($sheet);
66+
67+
// Save
68+
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Html', 'Dompdf', 'Mpdf']);
69+
$spreadsheet->disconnectWorksheets();

samples/images/blue_square.png

2.3 KB
Loading

samples/templates/27template.xlsx

582 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)