def do_fill_workbook(self, workbook):
"""export to excel all articles tin stock"""
sheet = workbook.add_sheet(_(u"Stock"))
line = 0
columns = [
_(u'Id'), _(u'Name'), _(u'Category'), _(u'Purchase price'), _(u"Stock count"), _(u'Stock threshold'),
_(u'Value'),
]
for col, label in enumerate(columns):
self.write_cell(sheet, 0, col, label, style=self.get_header_style())
for line, item in enumerate(self.get_store_items()):
sheet.write(line + 1, 0, item.id)
sheet.write(line + 1, 1, item.name)
sheet.write(line + 1, 2, u'{0}'.format(item.category) if item.category else '')
sheet.write(line + 1, 3, item.purchase_price if item.purchase_price else 0)
sheet.write(line + 1, 4, '' if item.stock_count is None else item.stock_count)
sheet.write(line + 1, 5, '' if item.stock_count is None else item.stock_threshold)
sheet.write(line + 1, 6, xlwt.Formula('D{0}*E{0})'.format(line + 2)))
sheet.write(line + 3, 6, xlwt.Formula('SUM(G1:G{0})'.format(line + 2)))
评论列表
文章目录