The background:
1, used Python to execute the SQL and saved the output into DataFrame format using Pandas.
2, appended the output to my existing excel file as one new worksheet.
Below is my code:
from pandas import ExcelWriter
sql_20 = ''''''
db = cx_Oracle.connect('*****', '*******', '**********')
conn = db.cursor()
conn.execute(sql_20)
df = pandas.read_sql_query(sql_20,db)
print(df)
with ExcelWriter('GUCS6J-Job Data.xlsx', mode='a') as writer:
df.to_excel(writer, sheet_name=str(20))
writer.save()
Database: Oracle
Column A data type: date
The SQL result from Oracle:
The DataFrame print from Python:
So far so good
But what I got in the excel worksheet:
I am curious why I got the '##################' and the value of this cell is -693594 in the excel.
I hope I can get the same result as the DataFrame print in the excel file.