基本信息
源码名称:python 根据 出货记录生成客户出货对账单&合同
源码大小:6.07KB
文件格式:.py
开发语言:Python
更新时间:2018-06-14
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
由出货流水生成单个客户的对账单&合同。
# extract_data.py
# -*- coding: utf-8 -*-
# @Date : 2016/5/13 11:04 r_w_006可以写入了。改善记录。
# @Function: 流水中提取有效的出货数据,生成对账单。
# @Author : ThomasBao
'''
2016-5-20
输入:全部流水资料 如 e:20160519.xls
输出:客户出货.xls 客户合同.xls
1.筛选条件:
a客户名称 easygui.enterbox 瑞丰科技,可改客户名称
b合计金额不等于0 有效出货统计
c升级背景色=白色 (64) 未结款的
2016-5-15
增加索引型号
型号排列,对单价相同的型号求和;
'''
import os
import string
import xlrd
import xlwt
import easygui
def handle_data():
#"""处理数据"""
# from datetime import datetime
import time
font0 = xlwt.Font()
font0.name = 'Times New Roman'
font0.colour_index = 2
font0.bold = True
style0 = xlwt.XFStyle() # 默认格式 style0
style0.font = font0
style1 = xlwt.XFStyle() # 日期格式
style1.num_format_str = 'YYYY-MM-DD'
default_file = r'd:/20160509.xls'
input_file = easygui.enterbox(u'输入文件',title = 'please input filename',default ='',strip =False)
file = [default_file,input_file][input_file !='']
# default_custom_name = u'瑞丰科技' # row_input(u'请输入客户名称,如果回车默认清华时代') # 输入客户名称
# input_custom_name = raw_input(u'输入客户名称')
# custom_name = [default_custom_name,input_custom_name][input_custom_name !='']
# print "%s" %custom_name
# filepath = raw_input(u'pleease input the file path')
# filepath = [file,filepath][filepath != '']
default_custom_name = u'瑞丰科技'
input_custom_name = easygui.enterbox(u'输入客户名称')
custom_name = [default_custom_name,input_custom_name][input_custom_name !='']
data = xlrd.open_workbook(file,formatting_info = True)
table = data.sheet_by_index(0)
nrows = table.nrows # 行数
ncols = table.ncols # 列数
bill_file = xlwt.Workbook()
bill_sheet = bill_file.add_sheet(u'对账单'' ' custom_name)
bill_sheet.col(0).width = 2678
bill_sheet.col(1).width = 3999
bill_sheet.col(2).width = 3999
bill_sheet.col(3).width = 1500
bill_sheet.col(4).width = 2666
bill_sheet.col(5).width = 2888
'''
sdsd
'''
# 写入第一行标题
new_row = 0
bill_sheet.write(0,0,u'日期')
bill_sheet.write(0,1,u'型号')
bill_sheet.write(0,2,u'规格')
bill_sheet.write(0,3,u'数量')
bill_sheet.write(0,4,u'单价')
bill_sheet.write(0,5,u'合计')
bill_sheet.write(0,6,u'备注')
new_row = 1
totle_mm = 0
for i in range (1,nrows):
mm = table.cell(i,5).value
xfx = table.cell_xf_index(i,0)
xf = data.xf_list[xfx]
bgx = xf.background.pattern_colour_index
# bgx = table.cell(i,21).value # 以后这里用背景颜色= 黄色 替换 0x0d 黄
# print bgx
totle2 = table.cell(i,14).value
if mm == custom_name and bgx == 64 and totle2 !=0 : # 如果客户名称是所选客户,那么提取客户的资料
bill_sheet.write(new_row,0,table.cell(i,1).value,style1)
bill_sheet.write(new_row,1,table.cell(i,9).value)
bill_sheet.write(new_row,2,table.cell(i,10).value)
bill_sheet.write(new_row,3,table.cell(i,11).value)
bill_sheet.write(new_row,4,table.cell(i,13).value)
bill_sheet.write(new_row,5,table.cell(i,14).value)
bill_sheet.write(new_row,6,table.cell(i,5).value)
new_row =1
totle_mm = table.cell(i,11).value
# print bill_sheet.cell(new_row,5).value.encode('utf-8')
#print u'采集有效样机单数%d 合计数量 %d 个' %new_row %totle_mm
print (u'采集有效出货 合计数量 %d 个' %totle_mm)
bill_file.save(u'd:/' custom_name u'出货.xls');
print (u'出货' custom_name 'extract ok')
file = u'd:/' custom_name u'出货.xls'
data = xlrd.open_workbook(file,formatting_info = True)
table = data.sheet_by_index(0)
nrows = table.nrows # 行数
ncols = table.ncols # 列数
# 打开客户型号
if custom_name == u'清华时代' :
model = custom_name
else:
model = u'常规'
file2 = u'd:/' model u'型号.xls' #打开客户型号
data2 = xlrd.open_workbook(file2,formatting_info = True)
table2 = data2.sheet_by_index(0)
nrows2 = table2.nrows # 行数
ncols2 = table2.ncols
# 由出货记录生产对账合同。
list_products=[]
list_products.append(u'型号')
list_num = 1
for i in range(0,nrows): #扫描出货记录中所有型号
for j in range (0,list_num): #查询列表 中的型号与 出货记录有没有重复;
mm = list_products[j] #提取产品型号mm
tt = table.cell(i,1).value
if mm !=tt:
print (u'不同')
continue
else:
print (u'找到')
break
print (tt)
if mm !=tt:
list_products.append(tt)
list_num =1
list_products.sort()
print ('****************')
constact_file = xlwt.Workbook() #写合同
constact_sheet = constact_file.add_sheet(u'合同 ' custom_name)
constact_sheet.col(0).width = 2678
constact_sheet.col(1).width = 3999
constact_sheet.col(2).width = 3999
constact_sheet.col(3).width = 1500
return None
def main():
handle_data()
if __name__ == '__main__':
main()