Skip to main content

No project description provided

Project description

Library for config-based rendering tables to html or excel

Allows to create a config based on pydantic BaseModel:

from bmsdna.table_rendering import markdown_to_excel, ColumnConfig, TableRenderer

my_cols = [
    ColumnConfig(header_key="mail.date", field="start", format="datetime"),
    ColumnConfig(
        header="MyTool",
        align="left",
        field="customer_id",
        link=lambda _, c: some_tool_link(c.get("customer_id"), c.get("lng_code")),
    ),
    ColumnConfig(
        header="PDF",
        align="left",
        field="customer_id",
        link=lambda _, c: maybe_some_pdf_link(c.get("customer_id"), c.get("lng_code")),
    ),
    ColumnConfig(
        header_key="mail.subject",
        field="subject",
    ),
    ColumnConfig(
        header_key="customer.sales_l12m",
        field="sales_amount_l12m",
        format="float",
        format_nr_decimals=0,
    )
]
lng_code = "de"
lng_table_config = TableRenderer(
    my_cols,
    translator=lambda k, d: get_app_text(k, lng_code, d),
)
# we can make some html
html:str = lng_table_config.render_html(some_list_data)

# or also an excel
with xlsxwriter.Workbook() as wb:
    ws = ws.add_worksheet("sheet1")

    # we can also write some markdown to excel

    markdown_to_excel("# Ein Titel\nWir haben hier einen Text", ws, wb)

    # and add the table to it
    lng_table_config.render_into_sheet(some_list_data, ws, wb, offset_rows=10)

We use it internally to create Emails with Excel attachments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bmsdna_table_rendering-0.5.3.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bmsdna_table_rendering-0.5.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file bmsdna_table_rendering-0.5.3.tar.gz.

File metadata

  • Download URL: bmsdna_table_rendering-0.5.3.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bmsdna_table_rendering-0.5.3.tar.gz
Algorithm Hash digest
SHA256 be9d6d26fe9e6da0fa938677f4991aa23a1ea6aedf507f04e51071271541bfec
MD5 7f51f8d6b15d1f473cfd378bbcab5a3d
BLAKE2b-256 0be7cbf09e74716748d0c67e5b3e25344ad40ef18ea9a9cd29b6acf332f57ee6

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmsdna_table_rendering-0.5.3.tar.gz:

Publisher: python-publish.yml on bmsuisse/bmsdna.table_rendering

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bmsdna_table_rendering-0.5.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bmsdna_table_rendering-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3edf90fb7c5ad69b9918a1f0c310b915da58c0d62b8e1da3a0c61350189c1bfd
MD5 f26ee49b84fe76e3d24cc7edcb4ce0cf
BLAKE2b-256 b9a1948bcf01e24b9c74c6bb9117824027dec1b3ade51bd5e9051f213ba9e36f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmsdna_table_rendering-0.5.3-py3-none-any.whl:

Publisher: python-publish.yml on bmsuisse/bmsdna.table_rendering

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page