When I will Rerun the file it will get error like following
<p>IndexError: list index out of range.</p>

<p>my code is :</p>

<pre><code>from openpyxl import load_workbook
from common.log import logging

class TestData:
    def get_data(self):

        wb = load_workbook(filename="demo.xlsx")
        ws = wb.active
        ws['A2'] = "ammy"
        ws['A3'] = "raju"
        ws['B2'] = 50
        ws['B3'] = 60
        ws['A4'] = "Total2"
        ws['B4'] = ("=SUM(B2:B3)")
        wb.save('demo.xlsx')


if __name__=='__main__':
    print "start"
    obj = TestData()
    obj.get_data()
    print "end"
</code></pre>

<p>You need to be more specific, Try adding a try, except block in the get_data method and print the stack trace. </p>

<pre><code>import traceback  # for exception tracing 
class TestData:
    def get_data(self):
        try:
            wb = load_workbook(filename="demo.xlsx")
            ws = wb.active
            ws['A2'] = "ammy"
            ws['A3'] = "raju"
            ws['B2'] = 50
            ws['B3'] = 60
            ws['A4'] = "Total2"
            ws['B4'] = ("=SUM(B2:B3)")
            wb.save('demo.xlsx')
        excepct:
            traceback.format_exc()
</code></pre>

<p>I suspect that when you try to access demo.xlsx via ws['XX'] it is causing the error</p>

python openpyxl