Skip to main content

A wrapper for openpyxl to create and use resualbe style in write only mode

Project description

licence ci language

openpyxl_style_writer

This is a wrapper base on openpyxl package. The original feature to create resuable style (NameStyled) is not avaliable for write only mode. Thus this package aimed to provide a easy way for user to create resuable styles and use it on write only mode easily

Installation

$ pip install openpyxl_style_writer

Example

from openpyxl_style_writer import RowWriter
from openpyxl_style_writer import DefaultStyle, CustomStyle


if __name__ == '__main__':
    workbook = RowWriter()
    workbook.create_sheet('ExampleSheet')

    title = 'This is an example'
    row_title_1 = ['fruits', 'fruits', 'animals', 'animals']
    row_title_2 = ['apple', 'banana', 'cat', 'dog']
    data = [10, 20, 30, 40]

    # append single cell with Default Style
    workbook.row_append(title)
    workbook.set_cell_width(1, 30)
    workbook.create_row()
    for item in row_title_1:
        workbook.row_append(item)
    workbook.create_row()

    # set custom Default Style and append list in a row
    blue_font_style = {'color': '0000ff', 'bold': True, 'size': 8}
    DefaultStyle.set_default(font_params=blue_font_style)
    workbook.row_append_list(row_title_2)
    workbook.create_row()

    # create new Custom Style and give row_append_list a style
    pink_fill_style = {'patternType': 'solid', 'fgColor': 'd25096'}
    pink_style = CustomStyle(fill_params=pink_fill_style)
    workbook.row_append_list(data, pink_style)
    workbook.create_row()

    workbook.save('example.xlsx')

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

openpyxl_style_writer-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

openpyxl_style_writer-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file openpyxl_style_writer-1.0.0.tar.gz.

File metadata

  • Download URL: openpyxl_style_writer-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for openpyxl_style_writer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 299b1aaa92bc717088f2fc9889ddb5424f5a2b41569fdd98a63045d5e41b7810
MD5 6304d43e4d2c17a74ae4aa16948b1066
BLAKE2b-256 cd1c4888f8ca0e2850c95d71e460baf4ca35cc3d19f4f71b3faf38734d8926ad

See more details on using hashes here.

File details

Details for the file openpyxl_style_writer-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openpyxl_style_writer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c384ba8f2898141a28901685491efa52ac23330f86ec364ded370e42caa859e
MD5 803c5f9e57715400c3707098d5ce7cc0
BLAKE2b-256 e6d5a01c9849f62ea1b5d9287f7aba8fb8a95ade21a9b0f0c95207beffbc0223

See more details on using hashes here.

Supported by

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