Add a correct format date in Excel file with Python openpyxl

0 votes

I need to add a new line from an excel file to a dict that has a date value, but this date value was entered in text format in the excel file's cell f.  This is my code to accomplish that; the datetime issue is present.

fromisoformat(row['Date']). strftime("%d/%m/%Y")

 however, it was put into the Excel file in text format.

Declaration_dict = Excel_Dict(r"\\path_to_excel_file.xlsx")
    for row in Declaration_dict:
        if row['statut'] == 'OK':
            line_declaration = (row['Cle_modifiee'], row['via'], row['Reference'], datetime.fromisoformat(row['Date']).strftime("%d/%m/%Y"), row['Detail'], row['NOM'], row['User'], row['Metier'], row['Equipe'], row['Libelle'])
            sheet_stock.append(line_declaration)
Feb 9, 2023 in Others by Kithuzzz
• 38,010 points
2,080 views

1 answer to this question.

0 votes

Use just datetime.fromisoformat(row['Date']) but I didn't have a cell with date format, the cell is with Standard format

excel file result

answered Feb 9, 2023 by narikkadan
• 63,420 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

VBA code help - Add a line for each missing date with the start and end date defined in a cell

Try this: Sub FillDates() Dim ...READ MORE

answered Jan 24, 2023 in Others by narikkadan
• 63,420 points
651 views
0 votes
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,060 views
0 votes
1 answer
0 votes
1 answer

Is there any way in python to auto-correct spelling mistake in multiple rows of an excel files of a single column?

Use Spellchecker for doing your stuff: import pandas ...READ MORE

answered Oct 14, 2022 in Others by narikkadan
• 63,420 points
1,594 views
0 votes
1 answer

Export a simple Dictionary into Excel file in python

You can use pandas. import pandas as pd dict1 ...READ MORE

answered Oct 23, 2022 in Others by narikkadan
• 63,420 points
5,397 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP