Created
July 25, 2012 03:50
-
-
Save hiroshineya/3174261 to your computer and use it in GitHub Desktop.
openpyxl howto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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.' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
easy edit xlsx cell data.
http://packages.python.org/openpyxl/index.html