项目作者: potykion

项目描述 :
Create xlsx-tables from html-tables
高级语言: Python
项目地址: git://github.com/potykion/jinja2xlsx.git
创建时间: 2019-03-24T10:16:43Z
项目社区:https://github.com/potykion/jinja2xlsx

开源协议:

下载


jinja2xlsx

Create xlsx-tables from html-tables

Example

Given html table str

When render html to xlsx

Then result xlsx has table values

  1. from jinja2xlsx import render_xlsx
  2. from openpyxl import Workbook
  3. html_str = """<!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6. <meta charset="UTF-8">
  7. <title>Simple table</title>
  8. </head>
  9. <body>
  10. <table>
  11. <tbody>
  12. <tr>
  13. <td>1</td>
  14. <td>2</td>
  15. </tr>
  16. <tr>
  17. <td>3</td>
  18. <td>4</td>
  19. </tr>
  20. </tbody>
  21. </table>
  22. </body>
  23. </html>"""
  24. workbook: Workbook = render_xlsx(html_str)
  25. assert tuple(workbook.active.values) == ((1, 2), (3, 4))

Installation

  1. pip install jinja2xlsx

For images support:

  1. pip install jinja2xlsx[pil]

Development

Install dependencies:

  1. poetry install

For images support:

  1. poetry install -E pil

Run tests and linting:

  1. pre-commit run -a

Install pre-commit hooks:

  1. pre-commit install

Extra

Publish to PyPI

  1. poetry publish --build