Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Python open datetime object saved in excel as custom

$
0
0

I trying to save datetime object to xlsx as date format in cell. But what i have is Custom format. What i am doing wrong that output is Custom format. In input file also date is is custom format.

        //Input file is xls so i convert it to xlsx

        writer = pd.ExcelWriter('C:/Download/qaz.xlsx',
                                engine='xlsxwriter', mode='w', datetime_format='dd/mm/yyyy', 
                                date_format='dd/mm/yyyy')

        output = pd.read_excel('C:/IVRS/Download/qaz.xls').to_excel(writer, index=False)

        writer.save()

        wb = openpyxl.reader.excel.load_workbook('C:/Download/qaz.xlsx')
        ws = wb.active
        cell = ws['E4'].value
        //datetime.datetime

        nsmmyy=NamedStyle(name="cd1", number_format="DD-MM-YYYY")
        cell.style = nsmmyy

regards


Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>