Openpyxl Write Data to Cell | Openpyxl Write to Cell



  • We can add data to the excel file using the following Python code.
  • We will import the load_workbook function from the openpyxl module, then create the object of the file and pass file nameas an argument.
 Write Data to Cell

Write Data to Cell

Sample Code

from openpyxl import load_workbook
wb = load_workbook(r'Wikitechy.xlsx')  

sheet = wb.active
sheet['A1'] = 'Wikitechy'  

sheet.cell(row=2, column=2).value = 10  
wb.save(r'Wikitechy.xlsx')  

Read Also

Output




Related Searches to Openpyxl Write Data to Cell | Openpyxl Write to Cell