Skip to content

使用openpyxl xlwings处理数据时方便调用的函数

License

Notifications You must be signed in to change notification settings

cmacckk/exceltidy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Excel Tidy

PyPI version

在工作中遇到的一些需要处理的情况,编写为库,方便后续操作

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

from exceltidy.exceltidy import *

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_nameNone时读取返回第一个工作表

from exceltidy.exceltidy import *

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_singleopenpyxl_parser_merged_cell使用方法详见代码函数

About

使用openpyxl xlwings处理数据时方便调用的函数

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages