-
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
Include comments in HTML writer (#308) #310
Closed
Closed
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ff9b9f1
Include comments in HTML writer
criztovyl 1b99b62
Fix undefined variable
criztovyl 58ea23e
Changelog
criztovyl f648fdd
Code Style
criztovyl 6e33778
More Code Style
criztovyl 561fbc4
Feature Reference
criztovyl 452980b
Store comments in a div
criztovyl 05e32e6
Import comments from HTML
criztovyl 7f6db56
Add test for html comment reader
criztovyl 4d79028
Do not write comments for PDF
criztovyl b7f1e10
More test cases
criztovyl eb2eb59
Code Style
criztovyl 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Functional; | ||
|
||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PhpOffice\PhpSpreadsheet\RichText\RichText; | ||
|
||
class HtmlCommentsTest extends AbstractFunctional | ||
{ | ||
private $spreadsheet; | ||
|
||
public function providerCommentRichText() | ||
{ | ||
$valueSingle = 'I am comment.'; | ||
$valueMulti= 'I am ' . PHP_EOL . 'multi-line' . PHP_EOL . 'comment.'; | ||
|
||
$plainSingle = new RichText(); | ||
$plainSingle->createText($valueSingle); | ||
|
||
$plainMulti = new RichText(); | ||
$plainMulti->createText($valueMulti); | ||
|
||
$richSingle = new RichText(); | ||
$richSingle->createTextRun($valueSingle)->getFont()->setBold(true); | ||
|
||
$richMultiSimple = new RichText(); | ||
$richMultiSimple->createTextRun($valueMulti)->getFont()->setBold(true); | ||
|
||
$richMultiMixed = new RichText(); | ||
$richMultiMixed->createText('I am' . PHP_EOL); | ||
$richMultiMixed->createTextRun('multi-line')->getFont()->setBold(true); | ||
$richMultiMixed->createText(PHP_EOL . 'comment!'); | ||
|
||
return [ | ||
'single line plain text' => [$plainSingle], | ||
'multi-line plain text' => [$plainMulti], | ||
'single line simple rich text' => [$richSingle], | ||
'multi-line simple rich text' => [$richMultiSimple], | ||
'multi-line mixed rich text' => [$richMultiMixed], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider providerCommentRichText | ||
*/ | ||
public function testComments($richText) | ||
{ | ||
$this->spreadsheet = new Spreadsheet(); | ||
|
||
$this->spreadsheet->getActiveSheet()->getCell('A1')->setValue('Comment'); | ||
|
||
$this->spreadsheet->getActiveSheet() | ||
->getComment('A1') | ||
->setText($richText); | ||
|
||
$reloadedSpreadsheet = $this->writeAndReload($this->spreadsheet, 'Html'); | ||
|
||
$actual = $reloadedSpreadsheet->getActiveSheet()->getComment('A1')->getText()->getPlainText(); | ||
self::assertSame($richText->getPlainText(), $actual); | ||
} | ||
|
||
} |
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.
I am currently thinking about changing to this:
(The second last column)
What do you think?
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.
(Where
2
is the "only text contents" footnote)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.
@PowerKiKi Any thoughts on this? :)
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.
You mean from
●
to✖
? I think●
is the best fit according to legend "Partially supported"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.
Yup, that makes more sense. :)