Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workbook problem #274

Open
Meanodaddyo opened this issue Jan 28, 2024 · 1 comment
Open

Workbook problem #274

Meanodaddyo opened this issue Jan 28, 2024 · 1 comment

Comments

@Meanodaddyo
Copy link

Meanodaddyo commented Jan 28, 2024

from openpyxl import Workbook # Define column names COLUMN_NAMES = ['College Name', 'Call Letter', 'Email', 'Phone', 'State'] # Define data data = [ ['College A', 'ABC', 'collegea@example.com', '1234567890', 'State A'], ['College B', 'DEF', 'collegeb@example.com', '9876543210', 'State B'], ['College C', 'GHI', 'collegec@example.com', '4567890123', 'State C'] ] # Create a new workbook workbook = Workbook() # Select the active sheet sheet = workbook.active # Set column names for col_num, column_name in enumerate(COLUMN_NAMES, 1): cell = sheet.cell(row=1, column=col_num) cell.value = column_name # Set data for row_num, row_data in enumerate(data, 2): for col_num, cell_value in enumerate(row_data, 1): cell = sheet.cell(row=row_num, column=col_num) cell.value = cell_value # Save the workbook workbook.save('college_data.xlsx')

@zdavatz zdavatz changed the title from openpyxl import Workbook # Define column names COLUMN_NAMES = ['College Name', 'Call Letter', 'Email', 'Phone', 'State'] # Define data data = [ ['College A', 'ABC', 'collegea@example.com', '1234567890', 'State A'], ['College B', 'DEF', 'collegeb@example.com', '9876543210', 'State B'], ['College C', 'GHI', 'collegec@example.com', '4567890123', 'State C'] ] # Create a new workbook workbook = Workbook() # Select the active sheet sheet = workbook.active # Set column names for col_num, column_name in enumerate(COLUMN_NAMES, 1): cell = sheet.cell(row=1, column=col_num) cell.value = column_name # Set data for row_num, row_data in enumerate(data, 2): for col_num, cell_value in enumerate(row_data, 1): cell = sheet.cell(row=row_num, column=col_num) cell.value = cell_value # Save the workbook workbook.save('college_data.xlsx') Workbook probelm Jan 28, 2024
@zdavatz zdavatz changed the title Workbook probelm Workbook problem Jan 28, 2024
@zdavatz
Copy link
Owner

zdavatz commented Jan 28, 2024

what is your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants