Answers for "with open openpyxl how to wirte to the excel sheets"

0

with open openpyxl how to wirte to the excel sheets

# import openpyxl module 
import openpyxl 

# Call a Workbook() function of openpyxl 
# to create a new blank Workbook object 
wb = openpyxl.Workbook() 

sheet = wb.active 

# using sheet object's cell() method. 
c1 = sheet.cell(row = 1, column = 1) 

# writing values to cells 
c1.value = "ANKIT"

c2 = sheet.cell(row= 1 , column = 2) 
c2.value = "RAI"

c3 = sheet['A2'] 
c3.value = "RAHUL"

c4 = sheet['B2'] 
c4.value = "RAI"

# Anytime you modify the Workbook object 
# or its sheets and cells, the spreadsheet 
# file will not be saved until you call 
# the save() workbook method. 
wb.save("C:\\Users\\user\\Desktop\\demo.xlsx")
Posted by: Guest on February-04-2021

Code answers related to "with open openpyxl how to wirte to the excel sheets"

Python Answers by Framework

Browse Popular Code Answers by Language