Feb-03-2020, 03:44 PM
Hi there,
Trying to write simple class for writing data in to excel file.
first create workbook and saved to the given file name
Problem starting from this point
2) write data into excel file.
Thanks in advance!
Appreciate any help
Trying to write simple class for writing data in to excel file.
first create workbook and saved to the given file name
from openpyxl import Workbook() class Excel: wb = None ws = None1)Initialize the excel file . Successfully create the excel file and managed to save to file location
def initexcel(self,sheet_name) wb = Workbook() ws = wb.create_sheet(sheet_name,0) wb.save(filename) return ws
Problem starting from this point
2) write data into excel file.
def writeexcel(sheet_name, ro,col,data) ws = self.wb[sheet_name] # trying to activate the sheet using the sheet name. N not working ws.cell(column = col,row = ro, value = data #not workingWhat I need to do is to write data to excel file ( that have created using the first method initexcel). activate the sheet_name sheet and write data to cell ( ro,col)
Thanks in advance!
Appreciate any help
