number instead of date string when writing xlsx file
<p>In a LibreOffice xlsx cell, the value is like this: 01/13/2016.
When I am creating a new xlsx file using python2, then that 01/13/2016 is converting to 42461.</p>

<p>python code :</p>

<pre><code>sheet1.write(row,col,sheet.cell(row,col).value) 
tab_matching = 0
for sheet_name in book.sheet_names():   

temp_sheet_name = sheet_name.lower()
if temp_sheet_name == tab_name: 
    tab_matching = 1

    sheet = book.sheet_by_name(sheet_name)
    temp_sheet_name = file_prefix+part_file_name+"_"+file_type+".xlsx"
    if os.path.exists(detail_path):
        xlsx_file_name = detail_path+"/"+temp_sheet_name
    else:
        xlsx_file_name = dirname+"/"+temp_sheet_name

    new_book = xlsxwriter.Workbook(xlsx_file_name)
    sheet1 = new_book.add_worksheet()


    for row in range(sheet.nrows):

        for col in range(sheet.ncols):  
            sheet1.write(row,col,sheet.cell(row,col).value)     

    new_book.close()
</code></pre>

<p>Could you tell me why this is happening?</p>

<p>You could do this.</p>

<pre><code>&gt;&gt;&gt; import datetime
&gt;&gt;&gt; today=datetime.datetime.now()
&gt;&gt;&gt; today
datetime.datetime(2016, 8, 27, 1, 7, 1, 909049)
&gt;&gt;&gt; value=today.strftime("%d/%m/%Y")
'27/08/2016'
&gt;&gt;&gt; sheet1.write(row,col,sheet.cell(row,col).value)
</code></pre>

python libreoffice xlsxwriter