def write_description_to_excel(table_string, description_column): global work_sheet_index wb = openpyxl.load_workbook(table_location) ws = wb.active product_brand_key = extra_functions.value_key(description_column, work_sheet_index) ws[product_brand_key] = table_string wb.save(table_location)
def write_product_code_to_excel(image_file_names, image_names_cell_letter): global work_sheet_index work_sheet_index = 2 wb = openpyxl.load_workbook(table_location) ws = wb.active for i in range(len(image_file_names)): print('wbind: ', work_sheet_index) product_brand_key = extra_functions.value_key(image_names_cell_letter, work_sheet_index) ws[product_brand_key] = image_file_names[i] work_sheet_index += 1 wb.save(table_location)
def save_product_to_excel(): global work_sheet_index # loading the workbook wb = openpyxl.load_workbook(table_location) # wb.active returns a Worksheet object ws = wb.active # adding the data to the workbook main_category_key = extra_functions.value_key( product_data.main_category_cell_letter, work_sheet_index) ws[main_category_key] = product_data.main_category sub_category_key = extra_functions.value_key( product_data.sub_category_cell_letter, work_sheet_index) ws[sub_category_key] = product_data.sub_category product_title_key = extra_functions.value_key( product_data.product_title_cell_letter, work_sheet_index) ws[product_title_key] = product_data.product_title product_id_key = extra_functions.value_key( product_data.product_id_cell_letter, work_sheet_index) ws[product_id_key] = product_data.product_id price_text_key = extra_functions.value_key( product_data.price_text_cell_letter, work_sheet_index) ws[price_text_key] = product_data.price_text old_price_text_key = extra_functions.value_key( product_data.old_price_text_cell_letter, work_sheet_index) ws[old_price_text_key] = product_data.old_price_text description_key = extra_functions.value_key( product_data.description_cell_letter, work_sheet_index) ws[description_key] = product_data.description ws[description_key].alignment = Alignment(wrapText=True) alcohol_concentration_key = extra_functions.value_key( product_data.alcohol_concentration_cell_letter, work_sheet_index) ws[alcohol_concentration_key] = product_data.alcohol_concentration brand_key = extra_functions.value_key(product_data.brand_cell_letter, work_sheet_index) ws[brand_key] = product_data.brand image_url_key = extra_functions.value_key( product_data.image_url_cell_letter, work_sheet_index) ws[image_url_key] = product_data.image_url time_key = extra_functions.value_key(product_data.time_letter, work_sheet_index) ws[time_key] = product_data.time time_difference_key = extra_functions.value_key( product_data.time_difference_letter, work_sheet_index) ws[time_difference_key] = product_data.time_difference # saving workbook wb.save(table_location)