Likely abandoned. No release or commit for years (last release over 6 years ago).
Consider insteadpyopenxlsxPythie’s Index: 64524.2K downloads/moCompare →
pip install pyxlsxIntroduction
A package to read/write xlsx worksheet like dictionary, based on openpyxl.
Installation
- from pip
pip install pyxlsx
- download package and run setup.py
python setup.py install
Usage
- Create a new xlsx file and write to it
from pyxlsx import new_xlsx
with new_xlsx(filename) as wb:
ws = wb.create_sheet('sheet1')
# some operations
# or
wb = new_xlsx()
ws = wb.creat_sheet('sheet1') # create a new sheet with name 'sheet1'
# some operations
wb.save(filename)
- Open an existing xlsx file
from pyxlsx import open_xlsx
with open_xlsx(filename) as wb:
ws1 = wb.active # get active sheet
ws2 = wb['sheet2']
# some operations
# or
wb = open_xlsx(filename)
ws = wb['sheet2']
# some operations
wb.save()
# to save as another file
wb.save(another_filename)
- Append rows to a worksheet
ws = wb['sheet1']
ws.append(
["", "", "str('Unknown')", "float(4.5)", "int(500)"]
)
# keys can only be of type str
content1 = {
'id': '001',
'productName': 'pork',
'productType': 'meat',
'price': 2.5,
'weight': 1000,
}
content2 = {
'id': '002',
'productName': 'beef',
'productType': 'meat',
'price': 4.5,
'weight': 1000,
'origin': 'Australia'
}
# header is auto-generated from keys of the dict the first time append_by_header is called.
ws.append_by_header(content1)
# new header name will be append to header if append_header is True (default value)
ws.append_by_header(content2)
# below is the result of writing operation
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | str('Unknown') | float(30) | int(0) | |||
| 2 | id | productName | productType | price | weight |