/
output.py
48 lines (37 loc) · 1.25 KB
/
output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# -*- coding:utf-8
import logging
import os
from openpyxl import load_workbook
from contract import Contract
from invoice import Invoice
from details import Details
class OutputWorkbook:
CONTRACT_SHEET = u"合同"
INVOICE_SHEET = u"箱单发票"
DETAILS_SHEET = u"出仓明细"
def __init__(self,template, **kwargs):
self.template = template
#self.dest = dest
self.wb = load_workbook(template)
self.contract = Contract(self.wb.get_sheet_by_name(self.CONTRACT_SHEET))
self.invoice = Invoice(self.wb.get_sheet_by_name(self.INVOICE_SHEET))
self.details = Details(self.wb.get_sheet_by_name(self.DETAILS_SHEET))
def get_contract_sheet(self):
return self.contract
def get_invoice_sheet(self):
return self.invoice
def get_detail_sheet(self):
return self.details
def save(self,dest=None):
if dest is None:
dest = self.template
self.contract.fix_borders()
self.details.fix_borders()
#save here
self.contract.remove_empty_rows()
self.invoice.remove_empty_rows()
self.details.remove_empty_rows()
self.wb.save(dest)
if __name__=="__main__":
pass