|
- # -*- coding: utf-8 -*-
- import xlwings as xw
- import pandas as pd
- app = xw.App(visible=False, add_book=False)
- wkb = app.books.open('test11.xlsm')
- for wks in wkb.sheets:
- if wks.name != 'Sheet1':
- wks.delete()
- val = wkb.sheets[0].range('A2').options(
- pd.DataFrame, header=1, index=False, expand='table').value
- data = val.groupby('分类')
- for index, group in data:
- sht = wkb.sheets.add(name=index + '数据表', after=len(wkb.sheets))
- sht.range('A2').options(index=False).value = group
- wkb.save()
- wkb.close()
- app.quit()
复制代码 |
评分
-
3
查看全部评分
-
|