개요
xlsxwriter 를 이용하여 엑셀을 보다 쉽게 작성할 수 있도록 도와주는 라이브러리입니다. 헤더 및 스타일 등을 간단히 지정할 수 있습니다.
설치
pip install simple-excel
사용법
- header 의 key 를 기준으로 데이터를 가공하여 엑셀로 저장합니다.
save_to를 string 으로 지정하면./output디렉터리 아래 파일이 저장됩니다. - 셀 너비는 텍스트 길이에 따라 자동으로 늘어나지만, 완벽하게 최적으로 설정되지는 않습니다. 따라서 엑셀의 자동 조정기능을 통해 너비를 조정해야 합니다.
- 다양한 방식으로 작성할 수 있도록 구현했습니다.
1. 가장 간단한 사용법
# 기본 사용법
simple_excel = SimpleExcel(save_to="test").open()
simple_excel.header = {"이름": "이름", "휴대폰": "휴 대 폰", "가입일": "가입일"}
simple_excel.cell_styles = {"휴대폰": {"num_format": "@"}}
simple_excel.cell_comments = {"휴대폰": "- 를 제거한 후 입력해주세요."}
excel_body = list()
for x in range(1, 100):
excel_body.append({"이름": f"홍길동{x}", "휴대폰": f"0101234567{x:02d}", "가입일": "2025-01-01"})
simple_excel.body = excel_body
simple_excel.write_sheet()
simple_excel.close()
# with 구문 사용법 (close 생략 가능)
with SimpleExcel(save_to="test") as simple_excel:
simple_excel.header = {"이름": "이름", "휴대폰": "휴 대 폰", "가입일": "가입일"}
simple_excel.cell_styles = {"휴대폰": {"num_format": "@"}}
simple_excel.cell_comments = {"휴대폰": "- 를 제거한 후 입력해주세요."}
excel_body = list()
for x in range(1, 100):
excel_body.append({"이름": f"홍길동{x}", "휴대폰": f"0101234567{x:02d}", "가입일": "2025-01-01"})
simple_excel.body = excel_body
simple_excel.write_sheet("sheet name")
2. 시트별로 데이터를 나누어 작성
with SimpleExcel(save_to="test") as simple_excel:
simple_excel.header = {"이름": "이름", "휴대폰": "휴 대 폰", "가입일": "가입일"}
simple_excel.cell_styles = {"휴대폰": {"num_format": "@"}}
simple_excel.cell_comments = {"휴대폰": "- 를 제거한 후 입력해주세요."}
excel_body = list()
for x in range(1, 100):
excel_body.append({"이름": f"홍길동{x}", "가입일": "2025-01-01"})
simple_excel.body = excel_body
simple_excel.write_sheet("by name")
excel_body = list()
for x in range(1, 100):
excel_body.append({"휴대폰": f"1012345{x}", "가입일": "2025-01-01"})
simple_excel.body = excel_body
simple_excel.write_sheet("by tel")
3. 버퍼에 저장
buffer = BytesIO()
with SimpleExcel(save_to=buffer) as simple_excel:
simple_excel.header = {"이름": "이름", "휴대폰": "휴 대 폰", "가입일": "가입일"}
simple_excel.cell_styles = {"휴대폰": {"num_format": "@"}}
simple_excel.cell_comments = {"휴대폰": "- 를 제거한 후 입력해주세요."}
excel_body = list()
for x in range(1, 100):
excel_body.append({"이름": f"홍길동{x}", "휴대폰": f"0101234567{x:02d}", "가입일": "2025-01-01"})
simple_excel.body = excel_body
simple_excel.write_sheet()
# 다운로드 응답
response = HttpResponse(
buffer.getvalue(),
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
response['Content-Disposition'] = 'attachment; filename="report.xlsx"'
return response
Metadata
Release files for simple-excel 1.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_excel-1.4.6.tar.gz | 6.6 kB | Without provenance | Details for simple_excel-1.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_excel-1.4.6-py3-none-any.whl | Python 3 | none | any | Details for simple_excel-1.4.6-py3-none-any.whl |
Total release size: 13.6 kB
Release files / simple_excel-1.4.6.tar.gz
| Download URL | simple_excel-1.4.6.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a5de9d7ff166b145d9894156575eff8ec3d3b76ec383f3fb26bd6e7d70ddd0c
|
|
BLAKE2b-256 checksum How to use checksums |
c9362715d5c9369aa8163b9ac9be4d8785ed6671d96913b6113134aa331dcf80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / simple_excel-1.4.6-py3-none-any.whl
| Download URL | simple_excel-1.4.6-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9afc48fa6302cbc63c9275b41de03822d80984c41e28984d0b5dadc56fccc48
|
|
BLAKE2b-256 checksum How to use checksums |
344d3cb14a4ebe84105f06fd88fb1b49b84b74159416b75c95031ff62549f905
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for simple-excel 1.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.