|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 solojiajun 于 2020-3-19 02:54 编辑
import openpyxl as op
from openpyxl.utils.dataframe import dataframe_to_rows
import pandas as pd
class WeiXinClass:
def __init__(self):
self.wb = op.load_workbook(r"/Users/solojiajun/Desktop/数据分析/运行文件/收入分类.xlsx")
self.ws = self.wb["收入分类明细"]
self.df = pd.read_excel(r"/Users/solojiajun/Desktop/数据分析/运行文件/收入分类.xlsx", sheet_name=5,
dtype={"日期": str, "销量": str, "原价": str, "金额": str, "金额%": str}, skiprows=1)
# self.dataListWS = dataListWS
# self.storeIndex = {
#
# '体育西店': "Q",
# '番禺奥园广场店': "D",
# '珠影店': "O",
# '花城汇南区店': "G",
# '花城汇中区店': "P",
# '江南西店': "K",
# '北京路店': "L",
# '江南新地店': "H",
# '杨箕店': "N",
# '番禺永旺店': "E",
# '番禺市桥店': "F",
# '天河南店': "M",
# '华利路店': "I",
# '佳兆业店': "J",
# '石牌桥店': "R"
#
# }
# self.store = list(
# {x.value for x in self.ws["F"] if x.value != "门店" and x.value != None})
#
# self.storeData = {}
# for each in self.store:
# df = self.df[(self.df.门店 == each) & (self.df.支付类型 != "支付宝")]
# df = df.drop(['交易时间', '付款账号', '订单来源', '订单金额', '用户实付', '优惠券抵扣', '积分抵扣', '特权抵扣', '优惠活动',
# '砍价减免', '储值消费', '收银抹零', '支付平台优惠', '支付平台商家优惠', '美味优惠', '分账金额'],
# axis=1)
# self.storeData[each] = df
# def copy_data(self):
# for each in self.store:
# self.wb.create_sheet(title="%s" % each)
# ws = self.wb[each]
# df = self.storeData[each]
#
# total = df[["商户应收", "手续费", "结算金额"]].sum()
# df = df.append(total, ignore_index=True)
# df = df.fillna(value=" ")
#
# for eachData in dataframe_to_rows(df):
# ws.append(eachData)
# ws.column_dimensions.group("A", hidden=True)
#
# self.wb.save(r"/Users/solojiajun/Desktop/数据分析/运行结果/美味微信.xlsx")
#
# def send_data(self):
# for each in self.storeData:
# df = self.storeData[each]
# total = df[["手续费", "结算金额"]].sum()
# total["手续费"] = -total["手续费"]
# self.dataListWS["%s22" % self.storeIndex[each]].value = total["结算金额"]
# self.dataListWS["%s23" % self.storeIndex[each]].value = total["手续费"]
weixin = WeiXinClass()
print(weixin.df)
for i in weixin.ws[1]:
print(i.value)
UserWarning: Workbook contains no default style, apply openpyxl's default
warn("Workbook contains no default style, apply openpyxl's default")
红色字是报错的内容 代码里执行的内容都能打印出来 但是有warning
望各位高人指点指点
|
|