Skip to content
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

Allow HTML Reader to load from string #1136

Closed
wants to merge 2 commits into from
Closed

Allow HTML Reader to load from string #1136

wants to merge 2 commits into from

Conversation

gnat42
Copy link
Contributor

@gnat42 gnat42 commented Aug 9, 2019

We often want to export a table as an excel sheet. The system renders the html and it seems like a waste of time to write it to the file system to use the reader. This allows us to render the html and then just pass it to a reader

This is:

- [ ] a bugfix
- [x] a new feature

Checklist:

Why this change is needed?

Just allows Reader\Html to accept html content as a string instead of just a file.

@gnat42
Copy link
Contributor Author

gnat42 commented Aug 9, 2019

I can add the rest of the checklist items if this is something that you think you would merge

@PowerKiKi
Copy link
Member

It sounds like it could be useful, but to be merged the checklist will have to be completed and the code should not be duplicated, instead create a common private method used by both load and loadFromString. Most likely that new method would receive a DOMDocument. Also be sure to make use of $this->securityScanner

@gnat42
Copy link
Contributor Author

gnat42 commented Aug 12, 2019

@PowerKiKi Sounds good, I just didn't want to go to a whole lot of trouble if the basic idea wouldn't be accepted. I've rebased and re-worked the PR to include all checklist items. Let me know if there are any issues that need tweaking.

@codysnider
Copy link
Contributor

@gnat42 Let me know if you need help with this. I was planning to put something similar in today but looks like you are 90% there.

@gnat42
Copy link
Contributor Author

gnat42 commented Aug 13, 2019

What's missing? I added tests and docs and added to the changelog?

throw new Exception('Failed to load content as a DOM Document');
}

return $this->loadDom($dom, new Spreadsheet());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $this->loadDom($dom, new Spreadsheet());
return $this->loadDocument($dom, new Spreadsheet());

@codysnider
Copy link
Contributor

As far as I can tell, just that (picked up by scrutinizer).

@gnat42
Copy link
Contributor Author

gnat42 commented Aug 14, 2019

So I'm a bit confused as to how the code coverage decreased. I have a test that tests loadFromString and it passes, but the code coverage makes it out as if loadFromString isn't tested at all.

Edited: NVM... I found the issue, my test functions weren't named testCanX... so weren't being run, which is why the tests never found that I called loadDom and loadDocument in two different places... I'm assuming that now this should pass...

We often want to export a table as an excel sheet. The system renders the
html and it seems like a waste of time to write it to the file system to
use the reader. This allows us to render the html and then just pass it to
a reader
@codysnider
Copy link
Contributor

You may want to assign @PowerKiKi as both an assignee and a reviewer. I'm not a maintainer and haven't the means to approve or deny this PR.

@gnat42
Copy link
Contributor Author

gnat42 commented Aug 14, 2019

Hey @codysnider I'm not sure I'm able to assign anyone. Hopefully @PowerKiKi sees and assigns himself.

@PowerKiKi PowerKiKi closed this in 95c8bb9 Aug 17, 2019
@PowerKiKi
Copy link
Member

Thanks ! it has been merged as 95c8bb9 (with minor modifications)

PowerKiKi added a commit that referenced this pull request Aug 17, 2019
1.9.0

### Added

- When <br> appears in a table cell, set the cell to wrap [#1071](#1071) and [#1070](#1070)
- Add MAXIFS, MINIFS, COUNTIFS and Remove MINIF, MAXIF [#1056](#1056)
- HLookup needs an ordered list even if range_lookup is set to false [#1055](#1055) and [#1076](#1076)
- Improve performance of IF function calls via ranch pruning to avoid resolution of every branches [#844](#844)
- MATCH function supports `*?~` Excel functionality, when match_type=0 [#1116](#1116)
- Allow HTML Reader to accept HTML as a string [#1136](#1136)

### Fixed

- Fix to AVERAGEIF() function when called with a third argument
- Eliminate duplicate fill none style entries [#1066](#1066)
- Fix number format masks containing literal (non-decimal point) dots [#1079](#1079)
- Fix number format masks containing named colours that were being misinterpreted as date formats; and add support for masks that fully replace the value with a full text string [#1009](#1009)
- Stricter-typed comparison testing in COUNTIF() and COUNTIFS() evaluation [#1046](#1046)
- COUPNUM should not return zero when settlement is in the last period [#1020](#1020) and [#1021](#1021)
- Fix handling of named ranges referencing sheets with spaces or "!" in their title
- Cover `getSheetByName()` with tests for name with quote and spaces [#739](#739)
- Best effort to support invalid colspan values in HTML reader - [#878](#878)
- Fixes incorrect rows deletion [#868](#868)
- MATCH function fix (value search by type, stop search when match_type=-1 and unordered element encountered) [#1116](#1116)
- Fix `getCalculatedValue()` error with more than two INDIRECT [#1115](#1115)
- Writer\Html did not hide columns [#985](#985)
@gnat42 gnat42 deleted the patch-1 branch August 23, 2019 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants