{"id":25588655,"url":"https://github.com/toaco/tablereport","last_synced_at":"2026-01-20T09:34:26.582Z","repository":{"id":144103620,"uuid":"99707720","full_name":"toaco/tablereport","owner":"toaco","description":"A python library for making table report.","archived":false,"fork":false,"pushed_at":"2020-06-04T13:10:29.000Z","size":173,"stargazers_count":55,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T22:05:13.193Z","etag":null,"topics":["excel","html","libreoffice","office","report","table","worksheet","wps"],"latest_commit_sha":null,"homepage":"http://tablereport.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-08-08T15:25:51.000Z","updated_at":"2025-03-13T06:55:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"74deda7f-c562-4c74-b0c5-7833a4bb70ab","html_url":"https://github.com/toaco/tablereport","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.0625,"last_synced_commit":"6d14ae92c97ae8b6604c2214e33e5e554ef54cdd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toaco%2Ftablereport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toaco%2Ftablereport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toaco%2Ftablereport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toaco%2Ftablereport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toaco","download_url":"https://codeload.github.com/toaco/tablereport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637770,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["excel","html","libreoffice","office","report","table","worksheet","wps"],"created_at":"2025-02-21T08:50:00.871Z","updated_at":"2026-01-20T09:34:26.573Z","avatar_url":"https://github.com/toaco.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tablereport\n\n![Python Version](https://img.shields.io/badge/python-2.7,3.4,3.5,3.6-blue.svg)\n[![Build Status](https://travis-ci.org/toaco/tablereport.svg?branch=master)](https://travis-ci.org/toaco/tablereport)\n[![Coverage Status](https://coveralls.io/repos/github/toaco/tablereport/badge.svg?branch=master)](https://coveralls.io/github/toaco/tablereport?branch=master)\n[![Code Health](https://landscape.io/github/toaco/tablereport/master/landscape.svg?style=flat)](https://landscape.io/github/toaco/tablereport/master)\n\nA python library for making table report. Now supports exporting to Excel.\n\n\n## Install \n\n```python\npip install git+https://github.com/DevineLiu/tablereport.git@master\n```\n\n\n## Example\n\n### Basic\n\n\n\n![](docs/images/basic.png)\n\n```python\nfrom tablereport import Table\nfrom tablereport.shortcut import write_to_excel\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4]])\n\nwrite_to_excel('basic.xlsx', table)\n```\n\n### Style\n\n![](docs/images/style.png)\n\n```python\nfrom tablereport import Table, Style\nfrom tablereport.shortcut import write_to_excel\n\ntable_style = Style({\n    'background_color': 'fff0f0f0',\n})\ntitle_style = Style({\n    'background_color': 'ff87cefa',\n    'font_weight': 'blod'\n}, extend=table_style)\n\nheader_style = Style({\n    'background_color': 'ff87cefa',\n}, extend=table_style)\ntable = Table(header=[[('TEST', title_style), None, None, None],\n                      [('HEADER1', header_style),\n                       ('HEADER2', header_style),\n                       ('HEADER3', header_style),\n                       ('HEADER4', header_style)]],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4]],\n              style=table_style)\n\nwrite_to_excel('style.xlsx', table)\n```\n\n### Column Selector\n\n![](docs/images/column_selector.png)\n\n```python\nfrom tablereport import Table, ColumnSelector, Style\nfrom tablereport.shortcut import write_to_excel\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4]])\n\nstyle = Style({\n    'background_color': 'fff0f0f0',\n})\nareas = table.body.select(ColumnSelector(lambda col: col % 2))\nareas.set_style(style)\nwrite_to_excel('column_selector.xlsx', table)\n```\n\n### Row Selector\n\n![](docs/images/row_selector.png)\n\n```python\nfrom tablereport import Table, RowSelector, Style\nfrom tablereport.shortcut import write_to_excel\n\nheader_style = Style({\n    'background_color': 'FF87CEFA',\n})\neven_row_style = Style({\n    'background_color': 'FFF0F0F0',\n})\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4],\n                    ['One', 'B', 1, 2], ])\n\ntable.header.set_style(header_style)\nrows = table.body.select(RowSelector(lambda line: not line % 2))\nrows.set_style(even_row_style)\nwrite_to_excel('row_selector.xlsx', table)\n```\n\n### Cell Selector\n\n![](docs/images/cell_selector.png)\n\n```python\nfrom tablereport import Table, Style, ColumnSelector, CellSelector\nfrom tablereport.shortcut import write_to_excel\n\ngood_score_style = Style({\n    'background_color': 'ff00cc33',\n})\nbad_score_style = Style({\n    'background_color': 'ffcc0000',\n})\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 90, 70],\n                    ['One', 'A', 50, 40],\n                    ['One', 'B', 93, 59],\n                    ['Two', 'A', 78, 23],\n                    ['Two', 'B', 28, 66]])\narea = table.body.select(ColumnSelector(lambda col: col == 3, width=2)).one()\ngood_score_cells = area.select(CellSelector(lambda cell: cell.value \u003e= 90))\nbad_score_cells = area.select(CellSelector(lambda cell: cell.value \u003c 60))\ngood_score_cells.set_style(good_score_style)\nbad_score_cells.set_style(bad_score_style)\n```\n\n### Merge\n\n![](docs/images/merge.png)\n\n```python\nfrom tablereport import Table, ColumnSelector\nfrom tablereport.shortcut import write_to_excel\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4]])\n\ncolumn = table.body.select(ColumnSelector(lambda col: col == 1)).one()\ncolumn.merge()\nwrite_to_excel('merge.xlsx', table)\n```\n\n### Group\n\n![](docs/images/group.png)\n\n```python\nfrom tablereport import Table, ColumnSelector\nfrom tablereport.shortcut import write_to_excel\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4],\n                    ['Two', 'A', 1, 2],\n                    ['Two', 'B', 2, 3]])\n\ncolumn = table.body.select(ColumnSelector(lambda col: col == 1)).one()\ncolumn.group().merge()\nwrite_to_excel('group.xlsx', table)\n```\n\n### Summary\n\n![](docs/images/summary.png)\n\n```python\nfrom tablereport import Table, Style\nfrom tablereport.shortcut import write_to_excel\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4]])\n\nstyle = Style({\n    'background_color': 'ffe6e6e6',\n})\ntable.body.summary(label='Total', label_span=2, label_style=style,\n                   value_style=style)\nwrite_to_excel('summary.xlsx', table)\n```\n\n### Horizontal Summary\n\n![](docs/images/horizontal_summary.png)\n\n```python\nfrom tablereport import Table, Style, ColumnSelector\nfrom tablereport.shortcut import write_to_excel\n\ntable = Table(header=[['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4],\n                    ['Two', 'A', 1, 2],\n                    ['Two', 'B', 2, 3]])\n\nheader_style = Style({\n    'background_color': 'ff87cefa',\n})\nsummary_style = Style({\n    'background_color': 'ffe6e6e6',\n})\n\nareas = table.select(ColumnSelector(lambda col: col == 3, width=2))\nsummary_style = Style({\n    'background_color': 'ffe6e6e6',\n})\nareas.summary(label_span=1, label='TOTAL', location='right',\n              value_style=summary_style, label_style=header_style)\ntable.header.set_style(header_style)\nwrite_to_excel('horizontal_summary.xlsx', table)\n```\n\n### Complex\n\n![](docs/images/complex.png)\n\n```python\nfrom tablereport import Table, ColumnSelector, Style\nfrom tablereport.shortcut import write_to_excel\n\ntitle_style = Style({\n    'font_size': 15,\n    'background_color': 'ff87cefa',\n    'font_weight': 'blod'\n})\n\nheader_style = Style({\n    'background_color': 'ff87cefa',\n})\n\nleft_total_style = Style({\n    'background_color': 'fff0f0f0',\n})\n\nbottom_total_style = Style({\n    'background_color': 'ffe6e6e6',\n})\n\ntable = Table(header=[['TEST', None, None, None],\n                      ['HEADER1', 'HEADER2', 'HEADER3', 'HEADER4']],\n              body=[['One', 'A', 1, 2],\n                    ['One', 'A', 2, 3],\n                    ['One', 'B', 3, 4],\n                    ['Two', 'A', 1, 2],\n                    ['Two', 'B', 2, 3]])\n\ntable.header[0].set_style(title_style)\ntable.header[1].set_style(header_style)\n\ncolumn = table.body.select(ColumnSelector(lambda col: col == 1)).one()\ncolumn.group().merge().left.summary(label_span=1, label='Total',\n                                    label_style=left_total_style,\n                                    value_style=left_total_style)\n\ntable.summary(label_span=2, label='Total',\n              label_style=bottom_total_style,\n              value_style=bottom_total_style)\n\nwrite_to_excel('complex.xlsx', table)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoaco%2Ftablereport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoaco%2Ftablereport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoaco%2Ftablereport/lists"}