I am new to Python. I need to write some data from my program to a spreadsheet. I\'ve searched online and there seem to be many packages available (xlwt, XlsXcessive, openpy
OpenPyxl
is quite a nice library, built to read/write Excel 2010 xlsx/xlsm files:
https://openpyxl.readthedocs.io/en/stable
The other answer, referring to it is using the deperciated function (get_sheet_by_name
). This is how to do it without it:
import openpyxl
wbkName = 'New.xlsx' #The file should be created before running the code.
wbk = openpyxl.load_workbook(wbkName)
wks = wbk['test1']
someValue = 1337
wks.cell(row=10, column=1).value = someValue
wbk.save(wbkName)
wbk.close