from openpyxl import Workbook from openpyxl.styles import Alignment def fillsheet(sheet,…
- User
from openpyxl import Workbook from openpyxl.styles import Alignment
def fill_sheet(sheet, sites): """ Fill the excel sheet with missed cells.
Args: sheet: openpyxl sheet object sites: list """ if len(sites) == 0: return columns = [ 'Region', 'ENM', 'ERBS_Name', 'ID', 'eNBId', 'Vlan', 'VlanRef', 'ExtEnodeB VlanRef', 'EranLink', 'PTP Time Sync', 'Elastic Ran LKF', 'Elastic Ran Feature', 'BBU', 'Port Bitrate', '10G LKF', '10G Feature', 'EUtranCells', 'Eran EUtranCells', ] row = 1 for col in columns: cell = sheet.cell(row=row, column=columns.index(col) + 1) cell.value = col row = 2 for site in sites: for col, cell_val in site.items(): col_index = columns.index(col) +1 cell = sheet.cell(row=row, column=col_index) cell.value = str(cell_val) row += 1def fill_excel(sites, path): """ Fill excel file with missed in atoll cells, each technology to separate sheet.
Args: selected_data: dict path: string """ work_book = Workbook() work_sheet = work_book.create_sheet('ElasticRan') fill_sheet(work_sheet, sites) del work_book['Sheet'] work_book.save(path) - Assistant
The code provided defines two functions:
fill_sheet()andfill_excel().The
fill_sheet()function takes in an openpyxl sheet object and a list of sites as arguments. It fills the sheet with the missed cells by iterating over the columns list and setting the value of each cell in the corresponding row and column index. The data for each site is retrieved from the sites list.The
fill_excel()function takes in a list of sites and a path as arguments. It creates a new workbook object usingopenpyxl.Workbook()and creates a new sheet named 'ElasticRan'. Then, it calls thefill_sheet()function to fill in the sheet with the missed cells data. Finally, it deletes the default 'Sheet' and saves the workbook to the specified path.To use these functions, you can call the
fill_excel()function with the appropriate arguments. The sites list should contain dictionaries where the keys are the column names and the values are the cell values for each site. The path argument should be a string representing the file path where the workbook should be saved. - User
Want to autofit for all columns except ‘EUtranCells’, ‘Eran EUtranCells’. For them what to apply text wrap
- Assistant
- User
How to set width for q and returns columns
- Assistant
- User
Add autohight
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.