[Answer]-Django 1.6 adding rows o excel sheet

1👍

✅

Finally I figured out the solution for adding rows to the table(with border) in excel sheet. I was using win32com port to do the task. Here is my code:

    import win32com.client as win32   

    exc = win32.gencache.EnsureDispatch("Excel.Application")

    exc.Workbooks.Open("E:\\Invoice.xls")



    exc.Visible = 1

    row = 1
    no=4
    i=1
    count=0
    for m in Eng_name:
        if(m!=""):
            count=count+1

    while True:
        exc.Range("B%d" % row).Select()
        data = exc.ActiveCell.FormulaR1C1
        exc.Range("A%d" % row).Select()
        condition = exc.ActiveCell.FormulaR1C1


        if condition == INSERT_THIS:
            if(i==count):
                 break
            exc.Rows("%d" %(row)).Select()
            exc.Selection.Insert(Shift=constants.xlDown)
            i=i+1
            print i


        else:

            row += 1

Leave a comment