Based on openpyxl and xlwings to facilitate Excel processing
Project description
Excel Tidy
在工作中遇到的一些需要处理的情况,编写为库,方便后续操作
openpyxl前缀的函数为基于openpyxl编写
xlwings同上
注意xlwings不支持linux,在linux上运行可能报错
使用方法
git clone https://github.com/cmacckk/exceltidy.git
安装依赖
pip install -r requirements.txt
openpyxl获取list[list, list, ...] openpyxl.workbook.Workbook openpyxl.worksheet.worksheet.Worksheet
worksheet_datas, workbook, worksheet = openpyxl_get_datas_workbook_worksheet(filename="./test.xlsx")
# 通过工作表获取数据
datas = openpyxl_get_datas(worksheet)
# 替换工作表数据
openpyxl_replace_worksheet_data(origin_worksheet, to_be_replaced_worksheet)
# 保存及关闭工作薄
workbook.save('./result.xlsx')
workbook.close()
xlwings获取App xw.Book xw.Sheet
sheet_name为None时读取返回第一个工作表
app, workbook, worksheet = xlwings_get_app_workbook_worksheet('./test.xlsx')
#
_, _, to_be_replaced_worksheet = xlwings_get_app_workbook_worksheet('./test2.xlsx', sheet_name='sort')
# 替换工作表数据
xlwings_replace_worksheet_data(origin_worksheet, to_be_replaced_worksheet)
# 排序
xlwings_sort(worksheet, "A4:L11", "L4:L11", 'descending')
# 保存及关闭工作薄、App
workbook.save()
workbook.close()
app.quit()
openpyxl_parse_multi_title_to_single及openpyxl_parser_merged_cell使用方法详见代码函数
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exceltidy-0.0.3.tar.gz.
File metadata
- Download URL: exceltidy-0.0.3.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf8002b2fc8fe4e74ecf5986a509f4cc2c2bffe2185174e86c01c5fbe57502a4
|
|
| MD5 |
379ea0bf4ad155e760f0072b951d8a84
|
|
| BLAKE2b-256 |
d10738d3bbc782e8b7af653dad9b5904ccf3ad31b88a8fb3f7d76b90ab796dcf
|
File details
Details for the file exceltidy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: exceltidy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f31242f134bccc0267666fc5b51a35890abfb429fba844ea7a4545fd1c0b85a
|
|
| MD5 |
1c4c012dc0bd4aa5b0ce916a77edbee2
|
|
| BLAKE2b-256 |
a91685bca783dfe38d01fae6302d114320dc65c39f9470681511004efebb136c
|