Skip to content

Instantly share code, notes, and snippets.

@hiroshineya
Created July 25, 2012 03:50
Show Gist options
  • Select an option

  • Save hiroshineya/3174261 to your computer and use it in GitHub Desktop.

Select an option

Save hiroshineya/3174261 to your computer and use it in GitHub Desktop.
openpyxl howto
#!/usr/bin/python
# -*- coding: utf-8 -*-
from openpyxl import load_workbook
if __name__ == "__main__":
print 'start.'
print ''
wb = load_workbook('load_test.xlsx')
sheet_names = wb.get_sheet_names()
for sheet_name in sheet_names:
print "sheet:%s" % sheet_name
sheet = wb.get_sheet_by_name(sheet_name)
#cell = sheet.cell('A1')
#print cell.value
#print ''
for i in range(0, 5):
for j in range(0, 5):
cell = sheet.cell(row=i, column=j)
if cell.value == None:
continue
print cell.value
if cell.value == u'あああ':
cell.value = u'いいい'
print ''
wb.save('load_test_out.xlsx')
print ''
print 'done.'
@hiroshineya

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment