Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
901 B
4
Indexable
Never
from openpyxl import Workbook
wb = Workbook()
c='y'
cell=2
while c=='y':
    cell=2
    name=input('Enter the customer name:')
    ws=wb.create_sheet(name)
    c2='y'
    while c2=='y':
        item=input('Enter item name:')
        price=float(input('Enter Price per Kilogram :'))
        weight=float(input('Enter weight :'))
        ws['A1']='Item'
        ws['B1']='price'
        ws['C1']='WEIGHT'
        ws['D1']='Total'
        ws['A'+str(cell)]=item
        ws['B'+str(cell)]=price
        ws['C'+str(cell)]=weight
        ws['D'+str(cell)]="=PRODUCT(B"+str(cell)+':C'+str(cell)+')'
        cell=cell+1
        c2=input('Do you want to add another item to the bill? (y, n):')
    
    ws['C'+str(cell+1)]='Total='
    ws['D'+str(cell+1)]="=SUM(D2"+':D'+str(cell-1)+')'
    c=input('Do you want to add another customer bill? (y, n):')
        
wb.save("Bill.xlsx") 
Leave a Comment