Akash
Akash

Reputation: 101

adding datetime into excel sheets using xls

I was using the library datetime and xlwt i wanted to create a sheet name and i want to add the date and time is has been created so i used the following lines.

sheet1 = wb.add_sheet('applied job list'+datetime.now())

it throwed an error saying

 File "d:/PROJECTS/job_apply_bot/aasda.py", line 5, in <module>
    sheet1 = wb.add_sheet('applied job list'+datetime.now())
TypeError: can only concatenate str (not "datetime.datetime") to str

idk what i am missing can someone help

Upvotes: 1

Views: 39

Answers (1)

Harvey Jones
Harvey Jones

Reputation: 26

Looks like your returning an object with datetime.now() try converting it to a string first like this,

sheet1 = wb.add_sheet('applied job list' + str(datetime.now()))

Upvotes: 1

Related Questions