-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
read hyperlink for drawing image #490
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ba9eb09
read hyperlink for drawing image
tezrik e85057b
code style fix
tezrik 5c3515a
add write support fore symetry
tezrik 7e95afa
document feature in docs/references/features-cross-reference.md
tezrik bb83901
cover with unit tests (see EnclosureTest example)
tezrik d0c5313
Code style fix
tezrik 2d2e61c
remove die
tezrik 98ead5b
extract read hyperlink
5befe13
bag fix
074018f
code style fix
a4e6b7c
code style fix
25a2121
Merge branch 'develop' into develop
tezrik ad89d0c
bag fix
5bb7fb4
Update code style and fix code
91a5de9
Revert: code style fix
2100a90
fix test
35eb2fb
fix bag
886ce8e
codestyle fix
524db77
fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
|
||
require __DIR__ . '/../Header.php'; | ||
$inputFileType = 'Xlsx'; | ||
|
||
|
||
$helper->log('Start'); | ||
|
||
|
||
$spreadsheet = new Spreadsheet(); | ||
|
||
$aSheet = $spreadsheet->getActiveSheet(); | ||
|
||
$gdImage = @imagecreatetruecolor(120, 20); | ||
$textColor = imagecolorallocate($gdImage, 255, 255, 255); | ||
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); | ||
|
||
$baseUrl = 'https://phpspreadsheet.readthedocs.io/'; | ||
|
||
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing(); | ||
$drawing->setName('In-Memory image 1'); | ||
$drawing->setDescription('In-Memory image 1'); | ||
$drawing->setCoordinates('A1'); | ||
$drawing->setImageResource($gdImage); | ||
$drawing->setRenderingFunction( | ||
\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG | ||
); | ||
$drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT); | ||
$drawing->setHeight(36); | ||
$helper->log('Write image'); | ||
|
||
$hyperLink = new \PhpOffice\PhpSpreadsheet\Cell\Hyperlink($baseUrl, 'test image'); | ||
$drawing->setHyperlink($hyperLink); | ||
$helper->log('Write link: ' . $baseUrl); | ||
|
||
$drawing->setWorksheet($aSheet); | ||
|
||
|
||
$filename = tempnam(\PhpOffice\PhpSpreadsheet\Shared\File::sysGetTempDir(), 'phpspreadsheet-test'); | ||
|
||
|
||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, $inputFileType); | ||
$writer->save($filename); | ||
|
||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); | ||
|
||
$reloadedSpreadsheet = $reader->load($filename); | ||
unlink($filename); | ||
|
||
$helper->log('reloaded Spreadsheet'); | ||
|
||
foreach ($reloadedSpreadsheet->getActiveSheet()->getDrawingCollection() as $pDrawing) { | ||
$helper->log('Read link: ' . $pDrawing->getHyperlink()->getUrl()); | ||
} | ||
|
||
$helper->log('end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: yuzhakov | ||
* Date: 08.05.18 | ||
* Time: 12:00. | ||
*/ | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Functional; | ||
|
||
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; | ||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; | ||
|
||
class DrawingImageHyperlinkTest extends AbstractFunctional | ||
{ | ||
/** | ||
* @throws \PhpOffice\PhpSpreadsheet\Exception | ||
*/ | ||
public function testDrawingImageHyperlinkTest() | ||
{ | ||
$baseUrl = 'https://github.com/PHPOffice/PhpSpreadsheet'; | ||
$spreadsheet = new Spreadsheet(); | ||
|
||
$aSheet = $spreadsheet->getActiveSheet(); | ||
|
||
$gdImage = @imagecreatetruecolor(120, 20); | ||
$textColor = imagecolorallocate($gdImage, 255, 255, 255); | ||
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor); | ||
|
||
$drawing = new MemoryDrawing(); | ||
$drawing->setName('In-Memory image 1'); | ||
$drawing->setDescription('In-Memory image 1'); | ||
$drawing->setCoordinates('A1'); | ||
$drawing->setImageResource($gdImage); | ||
$drawing->setRenderingFunction( | ||
MemoryDrawing::RENDERING_JPEG | ||
); | ||
$drawing->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT); | ||
$drawing->setHeight(36); | ||
$hyperLink = new Hyperlink($baseUrl, 'test image'); | ||
$drawing->setHyperlink($hyperLink); | ||
$drawing->setWorksheet($aSheet); | ||
|
||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); | ||
|
||
foreach ($reloadedSpreadsheet->getActiveSheet()->getDrawingCollection() as $pDrawing) { | ||
self::assertEquals('https://github.com/PHPOffice/PhpSpreadsheet', $pDrawing->getHyperlink()->getUrl(), 'functional test drawing hyperlink'); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not use file comment blocks, please remove. You will be credited in the commit information.