Permalink
Browse files

fix bug in writing blank cells to __cell, docs

  • Loading branch information...
1 parent 4eaab12 commit 6b2a8ae10b7fa6cea8376ed11385d4237659dde2 @rupa rupa committed Apr 20, 2012
Showing with 13 additions and 7 deletions.
  1. +7 −2 README.rst
  2. +6 −5 xlsx/__init__.py
View
@@ -13,7 +13,7 @@ Usage
::
- book = Workbook('filename or filedescriptor') #Open xlsx file
+ book = Workbook('filename or filedescriptor') # Open xlsx file
for sheet in book:
print sheet.name
for row, cells in sheet.rows().iteritems(): # or sheet.cols()
@@ -24,7 +24,12 @@ Usage
# or you can access the sheets by their name:
some_sheet = book['some sheet name']
- ...
+
+ # rows, columns, and cells can be accessed directly from sheets
+
+ some_sheet['AA'] # column AA
+ some_sheet['6'] # row 6
+ some_sheet['AA6'] # cell in column AA row 6
Alternatives
------------
View
@@ -147,19 +147,20 @@ def __load(self):
# fill in missing cells
col_idx = xlcol2num(colNum)
if not cell_ids and col_idx > 1:
- print colNum, 'first'
for i in range(1, col_idx):
- cell = Cell(rowNum, num2xlcol(i), u'', formula=None)
+ xlcol = num2xlcol(i)
+ cell = Cell(rowNum, xlcol, u'', formula=None)
rows[rowNum].append(cell)
columns[colNum].append(cell)
- self.__cells[u'{0}{1}'.format(colNum, rowNum)] = cell
+ self.__cells[u'{0}{1}'.format(xlcol, rowNum)] = cell
cell_ids.append(col_idx)
elif cell_ids and col_idx > cell_ids[-1] + 1:
for i in range(cell_ids[-1] + 1, col_idx):
- cell = Cell(rowNum, num2xlcol(i), u'', formula=None)
+ xlcol = num2xlcol(i)
+ cell = Cell(rowNum, xlcol, u'', formula=None)
rows[rowNum].append(cell)
columns[colNum].append(cell)
- self.__cells[u'{0}{1}'.format(colNum, rowNum)] = cell
+ self.__cells[u'{0}{1}'.format(xlcol, rowNum)] = cell
cell_ids.append(col_idx)
cell_ids.append(col_idx)

0 comments on commit 6b2a8ae

Please sign in to comment.