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

Added initial support to support HTML formatting. #278

Merged
merged 8 commits into from
Apr 15, 2016
Merged

Added initial support to support HTML formatting. #278

merged 8 commits into from
Apr 15, 2016

Conversation

welguisz
Copy link
Contributor

@welguisz welguisz commented Dec 4, 2015

Goal: Support HTML Mark-up for sub, sup, b, i, u in individual cells
Method:

  • Read through shared_strings
  • If element is t, it is the same as text
  • If element is r, it is formatted text
    ** rPr contains the formatting options
    ** t contains the text
  • Set up hash for different elements ... default value for each key is false
  • if rPr contains the following change hash[key] to true
rPr element hash key
b b
i i
u u
vertAlign="subscript" sub
vertAlign="superscript" sup
  • Write an html string which a user can use Nokogiri::XML to convert from string to XML/HTML

Known Issue:

  • Possible speed issue.

def use_html?(index)
ret_val = false
return false if to_a[index].nil?
return true if to_html[index].include?('<sub>')
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use a regexp here, e.g.

to_html[index][/<([biu]|sub|sup)>/]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change.

@stevendaniels
Copy link
Contributor

Is it possible to add more tests for these situations?

@welguisz
Copy link
Contributor Author

I will write some unit tests this weekend and add them to git.

@welguisz
Copy link
Contributor Author

Everything looks good from my side. Thanks,

@welguisz
Copy link
Contributor Author

welguisz commented Mar 4, 2016

@stevendaniels Anything that I can do to push this along. I know that some of my co-workers and developers are looking toward this.

Also, sometime next week I was thinking of adding formatting to the output stream so that Mike<sub>drop</sub> would display as Mikedrop in Excel cell.

@ilyasgaraev
Copy link

@stevendaniels @welguisz Hi guys! Could you please let me know what state this pull request is in? Are you planning to merge it, and if so, when? Thanks!

@welguisz
Copy link
Contributor Author

@ilyasgaraev ... It is in a state to be merged. I have not had time to do an output to Excel Cell yet. The import of the HTML tags is ready. Up to @stevendaniels to decide when he wants to pull it in. I don't have the ability to do a merge to the main repository.

@stevendaniels stevendaniels merged commit 4294ea4 into roo-rb:master Apr 15, 2016
@stevendaniels
Copy link
Contributor

I'll be releasing a new version soon.

jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 15, 2016
## [2.5.1] 2016-08-26
### Fixed
- Fixed NameError. [337](roo-rb/roo#337)

## [2.5.0] 2016-08-21
### Fixed
- Remove tempdirs via finalizers on garbage collection. This cleans them up in all known cases, rather than just when the #close method is called. The #close method can be used to cleanup early. [329](roo-rb/roo#329)
- Fixed README.md typo [318](roo-rb/roo#318)
- Parse sheets in ODS files once to improve performance [320](roo-rb/roo#320)
- Fix some Cell conversion issues [324](roo-rb/roo#324) and [331](roo-rb/roo#331)
- Improved memory performance [332](roo-rb/roo#332)
- Added `no_hyperlinks` option to improve streamig performance [319](roo-rb/roo#319) and [333](roo-rb/roo#333)

### Deprecations
- Roo::Base::TEMP_PREFIX should be accessed via Roo::TEMP_PREFIX
- The private Roo::Base#make_tempdir is now available at the class level in
  classes that use tempdirs, added via Roo::Tempdir
=======
### Added
- Discard hiperlinks lookups to allow streaming parsing without loading whole files

## [2.4.0] 2016-05-14
### Fixed
- Fixed opening spreadsheets with charts [315](roo-rb/roo#315)
- Fixed memory issues for Roo::Utils.number_to_letter [308](roo-rb/roo#308)
- Fixed Roo::Excelx::Cell::Number to recognize floating point numbers [306](roo-rb/roo#306)
- Fixed version number in Readme.md [304](roo-rb/roo#304)

### Added
- Added initial support for HTML formatting [278](roo-rb/roo#278)
@ewmanthei
Copy link

ewmanthei commented Dec 6, 2016

Would it be possible to add an option to disable this feature? Something like:
xlsx = Roo::Spreadsheet.open('./myfile.xlsx', injectHtmlWrapper: false)

To be completely honest, this should be disabled by default and the option should be to enable it. Injecting anything into users' data should never be a default behavior.

@kaluznyo
Copy link

This features must be with option to disable. I try to import to my project a XLSX with html. My purpose is to get html like the excel, but roo wrap all my cell content with . Modify content is not very good

@welguisz welguisz deleted the html_strings branch May 12, 2017 13:47
@welguisz
Copy link
Contributor Author

@kaluznyo Here is the pull request for Disable HTML Injection

@welguisz welguisz mentioned this pull request Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants