Last active
September 12, 2016 07:06
-
-
Save asilachev/bad928827a96aa44de523760ad065161 to your computer and use it in GitHub Desktop.
OpenPyXl investigation
This file contains 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
from openpyxl import Workbook | |
from openpyxl.compat import range | |
from openpyxl.utils import get_column_letter | |
wb = Workbook() | |
dest_filename = 'empty_book.xlsx' | |
ws1 = wb.active | |
ws1.title = "range names" | |
for row in range(1, 40): | |
ws1.append(range(600)) | |
ws1.column_dimensions.group('A','D') | |
for idx in range(1, 20): | |
ws1.row_dimensions[idx].outlineLevel = 1 | |
for idx in range(10, 15): | |
ws1.row_dimensions[idx].outlineLevel = 2 | |
for idx in range(30, 40): | |
ws1.row_dimensions[idx].outlineLevel = 1 | |
ws2 = wb.create_sheet(title="Pi") | |
ws2['F5'] = 3.14 | |
ws3 = wb.create_sheet(title="Data") | |
for row in range(10, 20): | |
for col in range(27, 54): | |
_ = ws3.cell(column=col, row=row, value="{0}".format(get_column_letter(col))) | |
wb.save(filename=dest_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment