title: Python openpyxl - Read an Excel file and set null for blank cells
body: <pre><code>from openpyxl import load_workbook
  import json
  
  wb = load_workbook(filename='Deployment Plan_2015.xlsx',read_only=True)
  ws = wb['Deployment Plan']
  x = 4
  data = []
  
  for row in ws.rows:
      for cell in row:
              if not cell.value:
                      print('null')
                      x = x+1
              else:
                      print(ws['A'+str(x)].value)
                      data.append(ws['A'+str(x)].value)
                      x = x+1
  
  print(json.JSONEncoder(data).encode(data))
  </code></pre>
  
  <p>It only reads the first the first cell(there are 4 more projects after Project 1) then prints everything as null:</p>
  
  <pre><code>Project 1
  null
  null
  </code></pre>
  
  <p>It continues for a few more nulls it ends with:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Maynor\Documents\Python\projects\DPprojectlister.py", line 15, in &lt;module&gt;
      print(ws['A'+str(x)].value)
    File "C:\Python34\lib\site-packages\openpyxl-2.2.2-py3.4.egg\openpyxl\worksheet\worksheet.py", line 400, in __getitem__
      return self._get_cell(key)
    File "C:\Python34\lib\site-packages\openpyxl-2.2.2-py3.4.egg\openpyxl\worksheet\iter_worksheet.py", line 168, in _get_cell
  cell = tuple(self.get_squared_range(col, row, col, row))[0]
  IndexError: tuple index out of range
  </code></pre>
  
  <p>It's suppose to print the data encoded in JSON after it reaches the end of the column</p>