I am trying to transfer my .csv output to .xslx as well but am having a bit of a trouble understanding how to loop through my sales with xlwt. I've read the following tutorials but no help there:
https://toricode.com/python-write-excel-file-using-xlwt/ and
https://tutorialmeta.com/question/understanding-for-loop-with-xlwt
The way it's done with csv.writer is as follows:
fieldnames = [
_("Date"),
_("Type"),
_("Price")
_("CustomerFName"),
_("CustomerLName"),
]
writer = csv.writer(output)
writer.writerow(fieldnames)
for s in sales:
for sale in s.sales.all():
row = [
s.date,
sale.type,
sale.price,
s.fName,
s.lName,
]
return output
Any ideas or good examples I could look into?
Thanks in advance.
Copyright Notice:Content Author:「simplyconfused」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71787306/python-xlwt-looping-through-sales-works-with-csv-writer